roattw Posted December 5, 2016 Report Share Posted December 5, 2016 Have a Datapage Form that sends the results of the completed form as an email notification. Would like to have the notification not send field data if it was left blank. Assume its JS added somewhere, maybe in the email fields: Age : [@field:Age] Quote Link to comment Share on other sites More sharing options...
MayMusic Posted December 6, 2016 Report Share Posted December 6, 2016 You need to create your email template in a text 6400 field probably and remove empty fields then use this field in email body. I have not had a chance to try it yet but this should help. Quote Link to comment Share on other sites More sharing options...
MayMusic Posted December 6, 2016 Report Share Posted December 6, 2016 Just tried this and it worked: <script> document.getElementById("Submit").onmouseover = function(){ var fname= document.getElementById("InsertRecordFirst_Name").value; var lname = document.getElementById("InsertRecordLast_Name").value; var age = document.getElementById("InsertRecordAge").value; var desc = document.getElementById("InsertRecordDescription2").value; var email=""; if (fname){ email=email +"\n" + "First Name= " + fname; } if (lname){ email=email +"\n" + "Last Name= " + lname ; } if (age){ email=email +"\n" + "Age= " + age ; } if (desc ){ email=email +"\n" + "Description= " + desc ; } document.getElementById("cbParamVirtual1").value = email; } </script> There are 4 fields to check and a virtual field which is being used as email body. Quote Link to comment Share on other sites More sharing options...
roattw Posted December 13, 2016 Author Report Share Posted December 13, 2016 Thank you. Does the script go in the Virtual Email field? Not sure exactly where this script gets placed. Quote Link to comment Share on other sites More sharing options...
roattw Posted December 13, 2016 Author Report Share Posted December 13, 2016 I set it up but its returning BLANK emails, no fields included. I added the Virtual Field: I added the HTML block with the script (full script below) Called the Virtual1 field into email notification body: Completing forms (with some blanks), the notification email is completely empty when received. Script used in HTML block: <script> document.getElementById("Submit").onmouseover = function(){ var Overnight= document.getElementById("InsertRecordOvernight").value; var Tx = document.getElementById("InsertRecordTreated").value; var No_tx = document.getElementById("InsertRecordReason_no_treat").value; var NoTxO = document.getElementById("InsertRecordNo_tx_other").value; var LVO = document.getElementById("InsertRecordLVO").value; var Init = document.getElementById("InsertRecordPt_initials").value; var Hosp = document.getElementById("InsertRecordHospital").value; var HspO = document.getElementById("InsertRecordHosp_other").value; var Age = document.getElementById("InsertRecordAge).value; var Sex = document.getElementById("InsertRecordGender").value; var LSN = document.getElementById("InsertRecordLSN_time").value; var LSNtime = document.getElementById("InsertRecordSpecific_LSN").value; var NIHSS = document.getElementById("InsertRecordNIHSS").value; var Eval = document.getElementById("InsertRecordEval_method").value; var Glu = document.getElementById("InsertRecordGlucose").value; var Interv = document.getElementById("InsertRecordIntervention").value; var DTG = document.getElementById("InsertRecordDTG_time").value; var DTN = document.getElementById("InsertRecordDTN_time").value; var Xfer = document.getElementById("InsertTransfer_UCMC").value; var Enroll = document.getElementById("InsertRecordEnrolled").value; var No_enroll = document.getElementById("InsertRecordReason_no_enroll").value; var MD = document.getElementById("InsertRecordMD_initials").value; var Comments = document.getElementById("InsertRecordComments").value; var email=""; if (Overnight){ email=email +"\n" + "O/N= " + Overnight; } if (Tx){ email=email +"\n" + "Tx= " + Tx; } if (No_tx){ email=email +"\n" + "No_tx= " + No_tx; } if (LVO){ email=email +"\n" + "LVO= " + LVO; } if (Init){ email=email +"\n" + "Init= " + Init; } if (Hosp){ email=email +"\n" + "Hosp= " + Hosp; } if (HspO){ email=email +"\n" + "HspO= " + HspO; } if (Age){ email=email +"\n" + "Age= " + Age; } if (Race){ email=email +"\n" + "Race= " + Race; } if (Sex){ email=email +"\n" + "Sex= " + Sex; } if (LSN){ email=email +"\n" + "LSN= " + LSN; } if (LSNtime){ email=email +"\n" + "LSNtime= " + LSNtime; } if (NIHSS){ email=email +"\n" + "NIHSS= " + NIHSS; } if (Eval){ email=email +"\n" + "Eval= " + Eval; } if (Glu){ email=email +"\n" + "Glu= " + Glu; } if (Interv){ email=email +"\n" + "Interv= " + Interv; } if (DTG){ email=email +"\n" + "DTG= " + DTG; } if (DTN){ email=email +"\n" + "DTN= " + DTN; } if (Xfer){ email=email +"\n" + "Xfer= " + Xfer; } if (Enroll){ email=email +"\n" + "Enroll= " + Enroll; } if (No_enroll){ email=email +"\n" + "No_enroll= " + No_enroll; } if (Trial){ email=email +"\n" + "Trial= " + Trial; } if (MD){ email=email +"\n" + "MD= " + MD; } if (Comments){ email=email +"\n" + "Comments= " + Comments; } document.getElementById("cbParamVirtual1").value = email; } </script> Probably missing something basic. Quote Link to comment Share on other sites More sharing options...
MayMusic Posted December 22, 2016 Report Share Posted December 22, 2016 Make sure virtual field on your submission page is either Hidden or Text not display only Quote Link to comment Share on other sites More sharing options...
Teshan Posted April 4, 2017 Report Share Posted April 4, 2017 Hi, "\n" does not creating a new line on email ? possible to pass the html tags instead ? Thank you Quote Link to comment Share on other sites More sharing options...
roattw Posted March 15, 2018 Author Report Share Posted March 15, 2018 Man, I just cant get this to work. Question, does the script go in HTML block or header? Quote Link to comment Share on other sites More sharing options...
roattw Posted April 19, 2018 Author Report Share Posted April 19, 2018 Data not getting passed correctly. Following the instructions I have: New Text Field (64000) to receive the email body: Does the Script go in Header? In header I have your script ending in: document.getElementById("cbParamVirtual5").value = email; } </script> New virtual and email field, hidden, receiving the Virtual5 script parameter: Im getting blank notification emails. Quote Link to comment Share on other sites More sharing options...
MayMusic Posted April 19, 2018 Report Share Posted April 19, 2018 You put the script in the Footer, make sure to uncheck HTML Editor in advanced tab Quote Link to comment Share on other sites More sharing options...
roattw Posted April 23, 2018 Author Report Share Posted April 23, 2018 Frustrating. Cant make it work ;^) Anyone need some freelance work? 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.