I am trying to get the script below to verify the "ReleasedIntoSystemBy" field (drop-down with email address values) is not blank. What have I got wrong?
// Declare the variable
var vEmail;
var vSubject = "New Work Order/Project Authorization"
var vBody = "Instructions:"
// Check that the email field is not null
if (xfa.resolveNode("#subform[0].#subform[2].Table111[1].Row1.ReleasedIn toSystemBy").rawValue !== null) {
vEmail = xfa.resolveNode("#subform[0].#subform[2].Table111[1].Row1.ReleasedInt oSystemBy").rawValue;
}
// Send email
event.target.submitForm({cURL:"mailto: " + vEmail + "?subject=" + vSubject + "&body=" + vBody,cSubmitAs:"PDF",cCharset:"utf-8"});
Yes - you are correct. I did as you suggested and changed it as seen below. Now it does nothing when blank. Is it possible to generate a message telling the user they left that field blank?
// Declare the variable
var vEmail;
var vSubject = "New Work Order/Project Authorization"
var vBody = "Instructions:"
// Check that the email field is not null
if (xfa.resolveNode("#subform[0].#subform[2].Table111[1].Row1.ReleasedIn toSystemBy").rawValue !== null) {
vEmail = xfa.resolveNode("#subform[0].#subform[2].Table111[1].Row1.ReleasedInt oSystemBy").rawValue;
// Send email
event.target.submitForm({cURL:"mailto: " + vEmail + "?subject=" + vSubject + "&body=" + vBody,cSubmitAs:"PDF",cCharset:"utf-8"});
}
Here you go
// Declare the variable
var vEmail;
var vSubject = "New Work Order/Project Authorization"
var vBody = "Instructions:"
// Check that the email field is not null
if (xfa.resolveNode("#subform[0].#subform[2].Table111[1].Row1.ReleasedIn toSystemBy").rawValue !== null) {
vEmail = xfa.resolveNode("#subform[0].#subform[2].Table111[1].Row1.ReleasedInt oSystemBy").rawValue;
// Send email
event.target.submitForm({cURL:"mailto: " + vEmail + "?subject=" + vSubject + "&body=" + vBody,cSubmitAs:"PDF",cCharset:"utf-8"});
}else{
//displays message box warning user to fill in field
xfa.host.messageBox("Please fill the email field");
//sets the focus to the field
xfa.host.setFocus(xfa.resolveNode("#subform[0].#subform[2].Table111[1 ].Row1.ReleasedIntoSystemBy"));
}
if you execute the below script it will check all validations on the form such as required fields
xfa.form.form1.execValidate()
form1 being the top node of you hierarchy
it will return a true or false, true if validatations are all fullfilled or false if not
In your script you could add an if statement similar to this
if(xfa.form.form1.execValidate() == true){
//within here execute your above email script
}
Having trouble - is this correct?
var vEmail;
var vSubject = "New Work Order/Project Authorization"
var vBody = "Instructions:"
if(xfa.form.form1.execValidate() == true){
// Check that the email field is not null
if (xfa.resolveNode("#subform[0].#subform[2].Table111[1].Row1.ReleasedIn toSystemBy").rawValue !== null) {
vEmail = xfa.resolveNode("#subform[0].#subform[2].Table111[1].Row1.ReleasedInt oSystemBy").rawValue;
}
// Send email
event.target.submitForm({cURL:"mailto: " + vEmail + "?subject=" + vSubject + "&body=" + vBody,cSubmitAs:"PDF",cCharset:"utf-8"});
}
North America
Europe, Middle East and Africa
Asia Pacific