Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • syn-rg 282 posts 425 karma points
    Mar 12, 2014 @ 07:03
    syn-rg
    0

    Send copy of form if checkbox value is true

    I'd like the a copy of the form sent to the submitter if the checkbox value is true.

    I've created a custom workflow, using the "send xslt transformed email, extended" option. I've filled the "Email (Enter the receiver email)" option with the "{emailaddress}" and included my XSLT.

    The form has a checkbox which by default is checked, this checkbox (Send me a copy) allows the submitter the option of having a copy of the form sent to them.

    So far I've tried the following option, but the form values are still being sent to the submitter.

    I want the submitter to only receive an email copy of the form if the checkbox is checked.

    Any help will be greatly appreciated. Cheers, JV

    <?xml version="1.0" encoding="utf-8"?>
    
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:user="urn:my-scripts" xmlns:umbraco.library="urn:umbraco.library" exclude-result-prefixes="xsl msxsl user umbraco.library">
    
      <xsl:output method="html" media-type="text/html" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" doctype-system="DTD/xhtml1-strict.dtd" cdata-section-elements="script style" indent="yes" encoding="utf-8"/>
      <xsl:param name="records" />
      <xsl:template match="/">
    
      <xsl:if test="$records//fields/sendmeacopy//value != '1'">
       <xsl:variable name="bodyText">
             <xsl:for-each select="$records//fields/child::*">
                      <strong><xsl:value-of select="./caption" />: </strong><xsl:value-of select=".//value" />&lt;br /&gt;&lt;br /&gt;
             </xsl:for-each>
        </xsl:variable>
        <xsl:value-of select="$bodyText"/>    
        <xsl:variable name="fromEmail" select="$records//fields/child::* [caption = 'Email address']//value" />
        <xsl:value-of select="umbraco.library:SendMail($fromEmail, '[email protected]', 'Subject', $bodyText, 'true')"/>
    
        </xsl:if>
    
      </xsl:template>
    </xsl:stylesheet>
    
  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    Mar 15, 2014 @ 09:49
    Jan Skovgaard
    0

    Hi JV

    At a first glance it seems like it's because your IF condition says if the senmeacopy//value is NOT 1...since you're using !1...What happens if you remove the "!" from the expression? Does it then work?

    /Jan

  • syn-rg 282 posts 425 karma points
    Mar 19, 2014 @ 07:27
    syn-rg
    0

    Hi Jan,

    If I remove the exclamation mark "!" nothing appears in the email, and the email still sends to the submitter.

    I don't want any email to be sent if they've unchecked the "send me a copy" checkbox.

    As an alternative I could use a "choose" which would allow me to change the text the submitter receives, so for those who uncheck the checkbox they can just receive an email letting them know the form has been submitted.

    But I would prefer no email to be sent if they have unchecked the checkbox.

    Cheers, JV

    Example of my "choose" option:

    <xsl:template match="/">
    
    <xsl:variable name="emailStr">
    
        <xsl:choose>
            <xsl:when test="$records//fields/child::* [name() = 'sendmeacopy']/.//value = 'True'">
                 <h3>Intro</h3>
    <p>
      Hello, this is a sample email using xslt to convert a record into a custom email
    </p>
    
    <h3>the fields</h3>
    <ul>
      <xsl:for-each select="$records//fields/child::*">
        <li>
          <h4>
            Caption: <xsl:value-of select="./caption"/>
          </h4>
          <p>
            <xsl:value-of select=".//value"/>
          </p>
        </li>
      </xsl:for-each>
    </ul>
    <p style="color:red;">This is for the ages: <xsl:value-of select="$records//fields/sendmeacopy//value"/></p>
    
    <h3>The actual xml</h3>
    <xsl:copy-of select="$records"/>
            </xsl:when>
            <xsl:otherwise>
            <p>Hi <xsl:value-of select="$records//fields/firstname//value"/>, your form submission has been successful.</p>
            </xsl:otherwise>
        </xsl:choose>
    
    </xsl:variable>
    
    <xsl:value-of disable-output-escaping="no" select="$emailStr" /> 
    

Please Sign in or register to post replies

Write your reply to:

Draft