Looking to lock form on email submission and set something from the form in the email subject

Avatar

Avatar

lostfrogg

Avatar

lostfrogg

lostfrogg

13-10-2020

I have added an email submission button. I've looked around but can't seem to find the answer to this - how do I lock the form on submission? The form has an auto-populate today's date box, and currently every time I open the form it resets it to the current date. 

Second, I have fields on the form for "forename" and "surname". Would it be possible to have the following in the "email subject": 

[specific text] - (forename initial) (surname initial)

 

Thanks!

Replies

Highlighted

Avatar

Avatar

Kosta_Prokopiu1

Employee

Avatar

Kosta_Prokopiu1

Employee

Kosta_Prokopiu1
Employee

28-10-2020

Use a DateTime field, set the patterns to time{HH:MM:SS} and Binding - Data Format to Time and the following script

if ($ == null) then
   $.rawValue = Num2Time(Time(), "HH:MM:SS")
endif

Highlighted

Avatar

Avatar

lostfrogg

Avatar

lostfrogg

lostfrogg

29-10-2020

Hi Kosta, with your help I managed to get the time to lock. I'm still working on the date but should be able to get there.

Regarding having the Forename & Surname initials in the email subject field, I have the following script in the presubmit, as javascript;

var sMailUrl=this.resolveNode("#event").submit.target;

this.resolveNode("#event").submit.target=sMailUrl + "?subject=Some Text "+form1.Page1subform.PatientSubform.Forname.rawValue+" "+form1.Page1subform.PatientSubform.Surname.rawValue + "(" + form1.Page1subform.PatientSubform.Forname.rawValue.substr(0,1) + form1.Page1subform.PatientSubform.Surname.rawValue.substr(0,1) + ")";

However, I am still getting generic text in the email subject field and not the "some text" and initials like I should. Do I need to change anything with this script? Add an email address or anything? Thanks!

Highlighted

Avatar

Avatar

lostfrogg

Avatar

lostfrogg

lostfrogg

29-10-2020

Hi Kosta, I have the following script in the "presubmit" area, running as Javascript;

var sMailUrl=this.resolveNode("#event").submit.target;
this.resolveNode("#event").submit.target=sMailUrl + "?subject=Referral to Liaison Psychiatry: "+form1.Page1subform.PatientSubform.Forname.rawValue+" "+form1.Page1subform.PatientSubform.Surename.rawValue;

When I submit the form however, the email title is still generic and does not incorporate the text or fields above. Any further help much appreciated. 

 

Highlighted

Avatar

Avatar

Kosta_Prokopiu1

Employee

Avatar

Kosta_Prokopiu1

Employee

Kosta_Prokopiu1
Employee

29-10-2020

I think that is the colon change it to Psychiatry\: then it should work.

Highlighted

Avatar

Avatar

lostfrogg

Avatar

lostfrogg

lostfrogg

29-10-2020

Thanks Kosta. I changed the script as you suggested, so it now reads (under presubmit, JavaScript):

var sMailUrl=this.resolveNode("#event").submit.target;
this.resolveNode("#event").submit.target=sMailUrl + "?subject=Referral to Liaison Psychiatry\: "+form1.Page1subform.PatientSubform.Forname.rawValue+" "+form1.Page1subform.PatientSubform.Surename.rawValue;

But when I submit the form and it attaches to an email, this is what I see in the subject line:

email.jpg

 

Highlighted

Avatar

Avatar

lostfrogg

Avatar

lostfrogg

lostfrogg

29-10-2020

Hi Kosta,

When I change the colon, so that the script under the preSubmit (JavaScript) window looks like this:

var sMailUrl=this.resolveNode("#event").submit.target;
this.resolveNode("#event").submit.target=sMailUrl + "?subject=Referral to Liaison Psychiatry\: "+form1.Page1subform.PatientSubform.Forname.rawValue+" "+form1.Page1subform.PatientSubform.Surename.rawValue;

I get a standard email subject line like this:

email.jpg

Highlighted

Avatar

Avatar

Kosta_Prokopiu1

Employee

Avatar

Kosta_Prokopiu1

Employee

Kosta_Prokopiu1
Employee

29-10-2020

Somehow your last question disappeared. I get the same when I switch from XML submit to PDF submit. I solved it by changing the Submit button as follows:

Kosta_Prokopiu1_0-1603986159792.png

Then I change the preSubmit script as follows (make sure that you replace the subject tag as defined above ("x"):

var sMailUrl=this.resolveNode("#event").submit.target;
sMailUrl = sMailUrl.substr(0,sMailUrl.indexOf("?subject=x")) + "?subject=Some Text\: " + Forname.rawValue + " " + Surename.rawValue + " (" + Forname.rawValue.substr(0,1) + Surename.rawValue.substr(0,1) + ")";
//contains the mailto: with the e-mail address
this.resolveNode("#event").submit.target=sMailUrl;

 

Highlighted

Avatar

Avatar

lostfrogg

Avatar

lostfrogg

lostfrogg

29-10-2020

Hi Kosta,

Yes that seemed to fix the issue! Thank you. One thing - with your script, I get this in the email subject header:

Some Text: sdf sdf (ss)

But what I am trying to get is:

Some Text: SS

I've been trying to delete the sdf bits but have been struggling to get it to work. Also not sure how to make the initials appear in capitals?

Highlighted

Avatar

Avatar

lostfrogg

Avatar

lostfrogg

lostfrogg

03-11-2020

Hi Kosta, not sure if you received my last message about having just the initials in capitals?

Highlighted

Avatar

Avatar

Kosta_Prokopiu1

Employee

Avatar

Kosta_Prokopiu1

Employee

Kosta_Prokopiu1
Employee

09-11-2020

🙂 I am off from time to time and the League is not my day job ....

I can see that scripting is not your strongest side. Change the line

 

this.resolveNode("#event").submit.target=sMailUrl + "?subject=Some Text "+Forname.rawValue+" "+Surename.rawValue + "(" + Forname.rawValue.substr(0,1) + Surename.rawValue.substr(0,1) + ")";

to

this.resolveNode("#event").submit.target=sMailUrl + "?subject=Some Text "+ Forname.rawValue.substr(0,1).toUpperCase() + Surename.rawValue.substr(0,1).toUpperCase();