Carlson Posted August 22, 2015 Report Share Posted August 22, 2015 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> menathansmith 1 Quote Link to comment Share on other sites More sharing options...
Carlson Posted August 22, 2015 Author Report Share Posted August 22, 2015 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> menathansmith 1 Quote Link to comment Share on other sites More sharing options...
Aurora Posted August 26, 2015 Report Share Posted August 26, 2015 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 menathansmith 1 Quote Link to comment Share on other sites More sharing options...
Carlson Posted August 26, 2015 Author Report Share Posted August 26, 2015 I was unable to get it to work. The "[@field:district_nbr]" is the field that is used to prevent the last record from repeating. This is currently working with my script above. What I would like to add is if statement that jumps to next record without submit, when calc field 1 = 0. menathansmith 1 Quote Link to comment Share on other sites More sharing options...
aam82 Posted August 27, 2015 Report Share Posted August 27, 2015 hmm, I could use this too. Aurora's code is working for me, with a calculated field. [@calcfield:1] But it will only process 2 records, then it seems to fail. I increased the timeout but that didn't help. Something wrong with the loop? menathansmith 1 Quote Link to comment Share on other sites More sharing options...
Carlson Posted August 28, 2015 Author Report Share Posted August 28, 2015 yes I only received 2 records and loop stopped. My original script above works with placing a stop value at the end of my table that is greater than the last record. I would like to get it to stop without having to place a stop record in my table. menathansmith 1 Quote Link to comment Share on other sites More sharing options...
Jan Posted September 5, 2015 Report Share Posted September 5, 2015 Hello everyone, I have found a solution, but it requires additional steps. 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]"). 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]"). 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. 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 menathansmith, LWSChad and DesiLogi 3 Quote Link to comment Share on other sites More sharing options...
aam82 Posted September 21, 2015 Report Share Posted September 21, 2015 Jan, I'm not sure if you mean for your script to replace Aurora's, or to be combined with it. Can you clarify? Thanks Quote Link to comment Share on other sites More sharing options...
Jan Posted September 22, 2015 Report Share Posted September 22, 2015 Hi aam82, I am afraid, my solution (all steps, not only the script) replaces Aurora's. menathansmith 1 Quote Link to comment Share on other sites More sharing options...
aam82 Posted September 22, 2015 Report Share Posted September 22, 2015 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! menathansmith 1 Quote Link to comment Share on other sites More sharing options...
Jan Posted September 22, 2015 Report Share Posted September 22, 2015 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. DesiLogi 1 Quote Link to comment Share on other sites More sharing options...
aam82 Posted September 23, 2015 Report Share Posted September 23, 2015 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. Quote Link to comment Share on other sites More sharing options...
aam82 Posted September 24, 2015 Report Share Posted September 24, 2015 FYI, I'm not able to get this working with a View datasource, only tables. I could be missing something, though I've checked and rechecked my values. When using a View, only one record is acted upon, then the script somehow reaches the completion case. Quote Link to comment Share on other sites More sharing options...
aam82 Posted September 24, 2015 Report Share Posted September 24, 2015 edit Quote Link to comment Share on other sites More sharing options...
menathansmith Posted September 27, 2015 Report Share Posted September 27, 2015 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 Quote Link to comment Share on other sites More sharing options...
Xiang Posted September 28, 2015 Report Share Posted September 28, 2015 Good morning menathansmith, I think, it's better to add a Header and Footer element, select the Footer element, click the Source button and enter the code. Does it work? Quote Link to comment Share on other sites More sharing options...
aam82 Posted October 22, 2015 Report Share Posted October 22, 2015 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. Quote Link to comment Share on other sites More sharing options...
aam82 Posted December 18, 2015 Report Share Posted December 18, 2015 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. Quote Link to comment Share on other sites More sharing options...
aam82 Posted March 30, 2016 Report Share Posted March 30, 2016 bump, please see my previous post directly before this one. thanks Quote Link to comment Share on other sites More sharing options...
aam82 Posted March 30, 2016 Report Share Posted March 30, 2016 Nevermind, this is better accomplished using the dynamic TO: setting on Automatic Emails-Insert and Update configuration page. That wasn't available when this workaround was developed. Quote Link to comment Share on other sites More sharing options...
Carlson Posted July 18, 2016 Author Report Share Posted July 18, 2016 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? Quote Link to comment Share on other sites More sharing options...
MayMusic Posted November 3, 2016 Report Share Posted November 3, 2016 Email trigger only fires on update/insert... Quote Link to comment Share on other sites More sharing options...
Hastur Posted March 26, 2019 Report Share Posted March 26, 2019 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. There are three rows with 1 value at the moment. 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.