Jump to content

Emails - Conditional On Checkboxes And Not Sending Every Time


Recommended Posts

I am new to using Caspio but am trying to figure out how to make the emails more conditional. It doesn't seem that there are options for different emails to be sent, based on criteria, per data page.

 

We have a web form, and then we have a tracker for our team. The team can check off boxes as items on the setup checklist are completed.

Ideally, I want a certain email to go to certain people when a certain checkbox is sent, and for that email to only go out when that checkbox is first checked. Not again just when other changes are made.

 

I know how to do the one checkbox and autosubmit thing, where an email is only sent if a checkbox is selected, but then if I make other updates it will resend that email, and that doesn't work. And it doesn't seem to be able to do multiples in a row like:

Submit

Goes to Datapage, sends email if match

Goes to next Datapage, sends email if match

etc. It just goes to one and then that ends the chain

 

So 1- any ideas? Other than creating separate data pages for the team to just update those checkboxes?

 

Also- is there a way to disable checking a checkbox once it's been checked? This doesn't seem to be a rule option.

 

Thank you!

Link to comment
Share on other sites

Hello Flosie,

 

I have an idea. I'll try explaining it, but if I'm unclear - ask more details :)

Add a Virtual field (it's should be Virtual1) and select the "Hidden" FormElement.

Then for every checkbox, you can add a Virtual field, select the CheckBox FormElement, and enter an email address in the "Value when checked" field.

Now you have a Hidden field and all your checkboxes and addresses.

Add Header&Footer element, select the Footer, click the Source button, and enter the following code.

If only one checkbox is present, you can use this code:

<SCRIPT LANGUAGE="JavaScript">

function create_list()
 {
   var emailsList = "myfirstEmail@mydomain.com";
   if(document.getElementById("cbParamVirtual2").checked) emailsList = emailsList + ";"+document.getElementById("cbParamVirtual2").value;
   document.getElementById("cbParamVirtual1").value = emailsList;
 }
 document.getElementById("caspioform").onsubmit=create_list;
</SCRIPT>

Please, enter a default address instead of "myfirstEmail@mydomain.com". For waht? If no checkboxes are checked, the DataPage will send an email to nobody, but it is a very bad practice, your Email can be marked as spam, if it sends emails to nobody.

 

If you have two checkboxes, you cope the line

if(document.getElementById("cbParamVirtual2").checked) emailsList = emailsList + ";"+document.getElementById("cbParamVirtual2").value;

Paste it and change both "2" to "3":

if(document.getElementById("cbParamVirtual3").checked) emailsList = emailsList + ";"+document.getElementById("cbParamVirtual3").value;

 

Now the code is:

<SCRIPT LANGUAGE="JavaScript">

function create_list()
 {
   var emailsList = "myfirstEmail@mydomain.com";

   if(document.getElementById("cbParamVirtual2").checked) emailsList = emailsList + ";"+document.getElementById("cbParamVirtual2").value;
   if(document.getElementById("cbParamVirtual3").checked) emailsList = emailsList + ";"+document.getElementById("cbParamVirtual3").value;

   document.getElementById("cbParamVirtual1").value = emailsList;
 }

 document.getElementById("caspioform").onsubmit=create_list;
</SCRIPT>

And so on.

 

The last thing - on the " Destination and Emails" screen, check "Acknowledgement email to email address submitted in form" and select Virtual1.

 

Now emails should be send by condition.

 

Please let me know if it works for you :)

Link to comment
Share on other sites

  • 6 months later...
  • 2 months later...

Can you explain the simpler way mentioned by the OP, "I know how to do the one checkbox and autosubmit thing, where an email is only sent if a checkbox is selected".  I can't find anywhere how to do it.  I have a Confirmation Email field which is the email address for each record.  When the check box is selected, I need the email to be sent to the address in that field.

Thanks

Link to comment
Share on other sites

If you have a simple 'check the box to send an email' the easiest way (from what I gather, I may be missing a solution) is to have 2 'Submit' buttons (they'd have to be custom buttons and the Style for the datapage would need to 'hide' the standard Submit button). 

To use this method:

1) have the 'check to email' box on the datapage

2) in 2 html blocks make custom Submit buttons: one is a 'Submit-to-Email' button that when clicked directs to a new datapage set to auto-sumbit (that has your fields for the email) and the second button a regular Submit button. 

3) put each submit html block/button in their own Section. 

4) make a rule so that if 'check to email' is un-checked then 'Hide' section with Submit-to-email button.

5) make a rule so that if 'check to email' is checked then 'Hide' section with regular Submit button. 

This way there will be a different 'submit' function depending on if the 'check to email' check box is checked. If it's checked it'll go to another datapage that autosubmits the email and if it's not checked it'll just submit like normal and not email anything. 

Link to comment
Share on other sites

The solution I would like to get working is this (from above):

<SCRIPT LANGUAGE="JavaScript">

function create_list()
 {
   var emailsList = "myfirstEmail@mydomain.com";
   if(document.getElementById("cbParamVirtual2").checked) emailsList = emailsList + ";"+document.getElementById("cbParamVirtual2").value;
   document.getElementById("cbParamVirtual1").value = emailsList;
 }
 document.getElementById("caspioform").onsubmit=create_list;
</SCRIPT>

Then you are supposed to set your Acknowledgement Email to Virtual 1 and make Virtual 2 a checkbox.  I want Virtual 2 to receive the parameter of the Confirmation Email field, which has the addresses I want to send to when the check box is checked.  I have tried setting this up, but I can't get it working.  I'd rather not make several extra Datapages just to send emails.

Thanks

Link to comment
Share on other sites

I just found the easiest way to send an email, conditional on a radio button, and it works great in my details page.  No Javascript, just a Virtual field.

My use case is that for some edits such as fixing a typo, I don't need to send a confirmation email to the originator of the record.  But for requested changes, such as a new location or phone number, I do need to send the confirmation email.  Each one of my records has a Confirmation_Email field that I needed to send to.

On Configure Details Page Fields, Create a Virtual field, we'll call it Virtual1.

Set Form Element to Radio Buttons

Source: Custom Values

If you want a "Don't Send" choice, Make a Value and type something like "No Email" in the Display field.  I set this one to Default.
(You should enter an email address for the value.  It should be a real address, like a catch-all so your emails don't get flagged for spam.)

You can create any number of bullet choices and, for instance, enter a person's name or department for the Display, and their email address for the value.  Set whatever one you wish to the default.

If the email address you need to send to is contained in a field, like mine was, then go to advanced and set it to receive a value on load.  Set it to Data Source Field and select your field for both Value and Text to Display.

Lastly under Destination and Emails, set your Acknowledgement Email to Virtual1.

On your details form, you will see a radio button for each choice you made and you can decide if, or who you want to email.

Link to comment
Share on other sites

  • 3 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...