Jump to content

Send multiply emails to addresses selected in list datatype field


Recommended Posts

Hi everyone,

I just want to share this solution.

If you need to generate notification emails to  email addresses selected in a list datatype,  you need to:

- add a virtual field;

- select a virtual field in the field "to" when you set-up notification email;

- insert the following script in the footer and replace list_of_emails with name of your list datatype field:

<script>
function ListToVirtual()
{
var ListValue = document.getElementsByName('ComboBoxInsertRecordlist_of_emails')[0].value;

var VirtualValue = document.getElementById('cbParamVirtual1');
VirtualValue.value = ListValue;

var str = document.getElementById("cbParamVirtual1").value; 
    var res = str.replace(/,/gi, ";");
    document.getElementById("cbParamVirtual1").value = res;
}

document.getElementById("caspioform").onsubmit=ListToVirtual;

</script>

 

Link to comment
Share on other sites

  • 2 months later...
  • 4 weeks later...

Hi Mathilda,

Can your solution be modified to do send notifications to multiple email addresses? I was trying out your solution, but realised that my email address is using text and not list datatype. 

What I'm trying to accomplish is to email to all the employees of selected companies based on user selection. However, Caspio does not support this and they recommended me to use bulk editing as a work around, It works but it requires extra steps and also extra datapages. I need a more elegant solution for my project.

Thanks

 

Email to multiple people.JPG

Link to comment
Share on other sites

On 7/27/2017 at 7:06 AM, SongLian said:

Hi Mathilda,

Can your solution be modified to do send notifications to multiple email addresses? I was trying out your solution, but realised that my email address is using text and not list datatype. 

What I'm trying to accomplish is to email to all the employees of selected companies based on user selection. However, Caspio does not support this and they recommended me to use bulk editing as a work around, It works but it requires extra steps and also extra datapages. I need a more elegant solution for my project.

Thanks

 

Email to multiple people.JPG

Hi, I took a solution from this post  and added a small script which will replace commas with semi column. 

Here is script which should be in the header:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>

<script>

window.onload = function multiselect() {

var a = document.getElementsByTagName('select');

var index;

for (index = 0; index < a.length; ++index) {

          if (a[index].size!==0) {

    a[index].multiple=true;


          }

}

}

</script> 

And the following script should be in the footer:


 

<script>

$('[name=cbParamVirtual2').change(function() {

$('[name=cbParamVirtual3').val($('[name=cbParamVirtual2').val())


});
</script>
<script>
function replace(){

var res=  document.getElementsByName('cbParamVirtual3')[0].value;

document.getElementsByName('cbParamVirtual3')[0].value=res.replace(",", "; ");

 
}
document.getElementById("caspioform").onsubmit=replace;
</script>

In my script Virtual field2 is a cascading element, Virtual field 3 is an additional field which should be used in the To field in email.

Hope that helps

Link to comment
Share on other sites

  • 2 weeks later...

Hi Mathilda,

Just found that there is still one problem with the script, the script works when 2 emails are selected, however, when I have 3 or more emails selected, the subsequent emails were not being sent as the divider between email was not replaced with semicolon

Please refer to the example of emails that I've managed to captured below, as you can see, only the 1st and 2nd email was replaced with semicolon but not the subsequent emails. 

tansonglian@gmail.com; tansonglian@yahoo.com,xxx@yahoo.com,song.lian.tan@recgroup.com

Appreciate if you can help to amend the script. 

Thanks in advance

Capture.JPG

Link to comment
Share on other sites

  • 2 weeks later...
On 8/15/2017 at 7:44 AM, SongLian said:

Hi Mathilda,

Just found that there is still one problem with the script, the script works when 2 emails are selected, however, when I have 3 or more emails selected, the subsequent emails were not being sent as the divider between email was not replaced with semicolon

Please refer to the example of emails that I've managed to captured below, as you can see, only the 1st and 2nd email was replaced with semicolon but not the subsequent emails. 

tansonglian@gmail.com; tansonglian@yahoo.com,xxx@yahoo.com,song.lian.tan@recgroup.com

Appreciate if you can help to amend the script. 

Thanks in advance

Capture.JPG

Hi SongLian, I changed code for the footer, it should work now:

<script>

$('[name=cbParamVirtual2').change(function() {

$('[name=cbParamVirtual3').val($('[name=cbParamVirtual2').val())


});
</script>
<script>
function replace(){

var res=  document.getElementsByName('cbParamVirtual3')[0].value;
var newchar = '; '
res = res.split(',').join(newchar);

document.getElementsByName('cbParamVirtual3')[0].value=res;

 
}
document.getElementById("caspioform").onsubmit=replace;
</script>

 

Link to comment
Share on other sites

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...