Jump to content

Use Virtual check box for condition to send emails


Recommended Posts

I've found a number of sort of related posts on this but nothing exact that I need.  

I have a tablular datapage with an internal Details page option that sends an Acknowledgement email for Update/Insert records. Works well except I need the user to be able to 'choose' whether to send the acknowledgement (or notification) email by checking a virtual field (check box). This is so an email doesn't go out every single time there's an edit- it only needs to go out when the users decides to by checking the virtual field. 

I'd like to possibly be able to use something like this on:

-and Inline Insert of a tabular datapage (though I don't think it could be virtual field then, perhaps I could put a check box in the data source table)

-a Bulk Edit popup

But the Details form of a tabular datapage is the first place I need to start. This seems like it should be a standard feature of CB because email notifications shouldn't go out every time an edit is made unless desired. Any help on this would be great- thanks. 

Link to comment
Share on other sites

When I had a similar need, I ended up using two datapages: one for the report and its functions, another for emails. In your case, the details page would link to a second datapage, that always sends emails on updates. This might work if you can separate the actions that should never trigger an email (let them do it on first page), and actions that should always trigger email (use link to 2nd datapage that always emails).

Link to comment
Share on other sites

I believe I found a workaround for this that might work well. Only problem is I need some help tweaking the javascript (my js knowledge is very limited). 

The concept is to use 3 Virtual fields on a Details datapage. 

Virtual 1 = hidden, default=blank

Virtual 2 = cascading text to get email address (you could use a non-virtual field for this, in my datapage I don't have the email address in the data source so a virtual field will retrieve it)

Virtual 3 = check box for option 'Send Email Notification'

Check in Email Options 'Acknowledgement Email' and select Virtual 1 for the 'Email Field' 

Now in the datapage footer, disable html editor and put javascript to see if Virtual 3 is 'checked'  or 'yes'.

If Virtual 3 is 'yes' then make Virtual 1 = Virtual 2 (because Virtual 2 has the email address in it). Else Virtual 1 = null. 

This way if Virtual 3 is checked an email address (Virtual 2) is copied to Virtual 1 and used for the Acknowledgement Email. If Virtual 3 is Not checked then Virtual 1 remains blank or null and so no email will be sent out. 

The issue I'm having is in the code itself- I'm not sure of the syntax exactly. I also have some other js running on Submit of the form and I need to incorporate this process into that existing code. 

In the datapage header I have 

<div id="cbmydetailsedit">

 

In the datapage footer I have 

<script>

$("#cbmydetailsedit form").submit(function(){
f_combination('EditRecordProjID', 'EditRecordProp_Display', 'EditRecordProjID_Prop_Display');

}

var v_db_email = "[@cbParamVirtual3]";
var v_n_email = $("#EditRecordcbParamVirtual3").prop('checked');
if(v_n_email && v_db_email!="Yes"){
$("#cbParamVirtual1").val("[@cbParamVirtual2]");
}
else{
$("#cbParamVirtual1").val("");
}

});

$(document).ready(function(){
var v_errmes = "An erro message specific to my app.";
f_modify_err_message("cb_value_present", "cb_not_valid_info",v_errmes);

});

</script>

</div>

 

Just to be clear, the code I inserted for the email notification choice is below. The rest of the code was there beforehand. I just need to make the insert work with the rest. 

var v_db_email = "[@cbParamVirtual3]";
var v_n_email = $("#EditRecordcbParamVirtual3").prop('checked');
if(v_n_email && v_db_email!="Yes"){
$("#cbParamVirtual1").val("[@cbParamVirtual2]");
}
else{
$("#cbParamVirtual1").val("");
}

 

So what I need to do is get the code to see if Virtual 3 is checked and, if so, make Virtual 1 = Virtual 2. Without interfering with the other functions already in there. The code above is the general way to do this, I believe, but the syntax is off. If anyone can help that would be really appreciated and this would be an excellent workaround till Caspio releases conditional email acknowledgements. 

 

Link to comment
Share on other sites

  • 3 weeks later...
  • 1 month later...

I just figured out 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 for this is that for some edits on my details page, 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, In the first value set, 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 subsequent 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 email field for both Value and Text to Display.

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

Result: on your details form, you will see a radio button for each choice you created 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...