Jump to content

Email Trigger Of Multiple Records


Recommended Posts

I am using a report detail datapage to generate multiple email notifications, where the details page destination is set to go to next record. Instead of having to click submit to generate each email for each record, I have added the auto submit script below. The only problem is that when a details page is set destination to next record, the auto submit will continue repeating at the last record instead of stopping after reaching the last record. Is there a way to modify the script below to tell it to stop autosubmitting after reaching the last record? Or alternatively can I tell it to only auto submit if the recordnumber is less than X?  Also can I have it display a message when it has reached the end of cycle?

 

As a solution with this script I am planning on using Windows Task Scheduler to auto open an html file and redirect to this datapage, so that I can auto schedule a multiple records email trigger.

 

<script type="text/javascript">
  if(document.getElementById("caspioform")) {
  document.getElementById("caspioform").style.display = 'none';
  setTimeout('document.forms["caspioform"].submit()',1000); } 
</script>
Link to comment
Share on other sites

I modified this script to stop at the last expected record.

 

Does anyone know how to modify the script to forward to the next record instead of autosubmit if the record contains a field with a certain value (only sending email notifications based on field value, else skipping to the next record and start check over)

 

<script type="text/javascript">
  if(document.getElementById("caspioform") && ("[@field:district_nbr]" <= "105")){
  document.getElementById("caspioform").style.display = 'none';
  setTimeout('document.forms["caspioform"].submit()',1000);
} else {document.write('<font face="arial" color=red size="5">Email Notifications have been Sent!');}
 
</script>
Link to comment
Share on other sites

Hello ccarls3

 

Please try the following script:

<script type="text/javascript">

if(document.getElementById("caspioform")){
     document.getElementById("caspioform").style.visibility = 'hidden';

if("[@field:district_nbr]" == "105"){     
     setTimeout('document.forms["caspioform"].submit()',1000);
} else {
     var v_link = document.getElementsByName("JumpToNext")[0];
     if(v_link){
          v_link.click();
     }
 document.write('<font face="arial" color=red size="5">Email Notifications have been Sent!');
}
}
</script>

Please let me know if the  script helps.

 

Regards, 

 

Aurora

Link to comment
Share on other sites

  • 2 weeks later...

Hello everyone,

 

I have found a solution, but it requires additional steps.

 

  1. Select the field with id or with any unique value, on the Advanced tab, select the Pass field value as parameter checkbox and copy the name of the parameter (for example, "[@id]").
  2. Add a Virtual field, select the Hidden Form element, select the External Parameters "On load, receive", paste the name of the parameter from step 1 (for example, "[@id]").
  3. Add the second Virtual field, select the Hidden Form element, select the Data Source Field "On load, receive", select the field with id or with any unique value, the field from step 1.
  4. Add the Header&Footer element, select the Footer element, click the Source button and enter the following script:
<script type="text/javascript">
if(document.getElementById("caspioform"))
{
if(document.getElementById("cbParamVirtual1").value==document.getElementById("cbParamVirtual2").value)
  {     
     document.getElementById("caspioform").style.visibility = 'hidden';
     document.write('<font face="arial" color=red size="5">Email Notifications have been Sent!');     
  }
else
  setTimeout('document.forms["caspioform"].submit()',1000);
}
</script>

I hope, it works. And it is not too complex :)

Link to comment
Share on other sites

  • 3 weeks later...

Hi aam82,

 

I am afraid, my solution (all steps, not only the script) replaces Aurora's.

 

Thanks, Jan, though in that case I don't think it's the best alternative.

 

The question here is how to auto-submit (and thereby e-mail notify), or skip to next record, based on the value of a calculated field.

 

For example, I tried to use it to auto-submit to all records in the datasource that also appear at least once (where count >=1) in some other table via a calcfield. Aurora's script works, but fails to loop through the entire dataset. Maybe it's just that the 'else-jump to next' condition isn't working?

 

This could be a very useful way of scheduling emails. Thanks for reading!

Link to comment
Share on other sites

Maybe, it is possible to merge both scripts (and three steps, that allow do not click the last record more than once):

<script type="text/javascript">
if(document.getElementById("caspioform"))
{
if(document.getElementById("cbParamVirtual1").value==document.getElementById("cbParamVirtual2").value)
  {     
     document.getElementById("caspioform").style.visibility = 'hidden';
     document.write('<font face="arial" color=red size="5">Email Notifications have been Sent!');     
  }
else
  {
    if("[@field:text]" == "105") { setTimeout('document.forms["caspioform"].submit()',1000); } 
    else 
      {
         var v_link = document.getElementsByName("JumpToNext")[0];
         if(v_link){ v_link.click(); }
       }
   }
}
</script>

I hope, it helps.

Link to comment
Share on other sites

Thank you, Jan, this works.

 

I just had to make a couple of changes to your instructions:

 

1. you must arrive at this auto-submit datapage with a unique id parameter already in the url. In other words, the URL that triggers this must be app.com/id=xyz, otherwise the first condition is met (blank=blank) on the first load, halting submissions

 

2. virtual1 receives the id parameter, but virtual2 should receive virtual1

 

Thanks again, this is so great.

Link to comment
Share on other sites

Getting same error.

Can you please tell me where I exactly put this code.

Little confused :(

 

Hello ccarls3

 

Please try the following script:

<script type="text/javascript">

if(document.getElementById("caspioform")){
     document.getElementById("caspioform").style.visibility = 'hidden';

if("[@field:district_nbr]" == "105"){     
     setTimeout('document.forms["caspioform"].submit()',1000);
} else {
     var v_link = document.getElementsByName("JumpToNext")[0];
     if(v_link){
          v_link.click();
     }
 document.write('<font face="arial" color=red size="5">Email Notifications have been Sent!');
}
}
</script>

Please let me know if the  script helps.

 

Regards, 

 

Aurora

 

Link to comment
Share on other sites

  • 4 weeks later...

Thanks again to Jan!

 

I had some trouble getting Jan's clever Virtual1 Virtual2 comparison condition work. First I think the condition was always met, because both values were null to begin with, so the script never went further than record 1. Then I thought I would load an external param into Virtual 1 to kick things off, but doing this will have that param persist through each record skip or update, because it's part of the url. I suppose that could work if you know the ID of your last record, and set that to your external param, but then you would have to update the value each time you add a record.

 

I'm currently passing the ID field to Virtual 1(same as above) on exit, and 'Receiving On Load' the 'Data Source'-ID field in Virtual 2. I don't remember seeing this as an option before, it might be part of the new update to Bridge.

 

You could probably directly compare the ID field to the Virtual, instead of using two Virtuals, but autonumber ID fields are not editable and so have a different HTML structure than other fields (you would have to target the label?), so it's easier to use two Virtual fields.

Link to comment
Share on other sites

  • 1 month later...

My ID field is not passing to Virtual1, which causes it to send over and over to the last record if the conditional is met.

 

I am using this on a Detail datapage, where if the condition is not met, go to next record, and the datapage destination option is go to next record. I don't think either case triggers an "exit" condition, which is needed for the native pass parameter feature.

Link to comment
Share on other sites

  • 3 months later...
  • 3 months later...

Since the enhancement with bulk record editing was released, I have used the bulk edit feature to trigger bulk email notifications. I would like to setup Windows Task Manager to open the datapage at a schedule date/time and generate the emails via bulk record update. Is it possible to add a script that would tell the datapage on load to automatically checkmark all records, go to bulk record update, and update (triggering the emails). This way I can schedule to email notifications to generate daily without having to manually run. Is this possible?

Link to comment
Share on other sites

  • 3 months later...
  • 2 years later...

Hello @Carlson

It is possible to implement such a script.
To do that, you need to define the field which you will use to set the criteria to slop the JS code.

Please find the example of the application attached.
For_Carlson_1_0_2019-Mar-26_1056.zip

Steps to use application:

1. Enable the deployment of the  "Test_Table_des Search and Report" Datapage

2. Open Preview of the " Test_Table_des Web Form" Datapage

3. Choose values to search for and to update. Use "1" as the search value and any value as a value for Update. 

joxi_screenshot_1553597008134.png.59da4aac095b2a2934d72d91786b6e7e.png

There are three rows with 1 value at the moment.

joxi_screenshot_1553596967105.png.74ceb6885664531f8cc46aa8b045923b.png

 

5. Click submit.

The submission form will redirect you to the details form. It will find all rows where Update_Value equal to 1. Then the JS code from the footer will update the values to 3 automatically.

Details datapage contains Calculated value. It counts all rows where Update_Value equal to 1. As soon as the result of Calculated value equal to 0, JS code stops.

You can apply this logic according to your needs.

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