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.ReleasedIntoSystemBy").rawValue !== null) {
vEmail = xfa.resolveNode("#subform[0].#subform[2].Table111[1].Row1.ReleasedIntoSystemBy").rawValue;
}
// Send email
event.target.submitForm({cURL:"mailto: " + vEmail + "?subject=" + vSubject + "&body=" + vBody,cSubmitAs:"PDF",cCharset:"utf-8"});
Solved! Go to Solution.
Views
Replies
Total Likes
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"));
}
Views
Replies
Total Likes
The script looks correct however, you are doing //Send Email script whether or not the vEmail value is null as it lies outside the if statement
I''m assuming you want to send if vEmail is not null. If that is the case then place the //Send Email script within the if statement.
Views
Replies
Total Likes
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.ReleasedIntoSystemBy").rawValue !== null) {
vEmail = xfa.resolveNode("#subform[0].#subform[2].Table111[1].Row1.ReleasedIntoSystemBy").rawValue;
// Send email
event.target.submitForm({cURL:"mailto: " + vEmail + "?subject=" + vSubject + "&body=" + vBody,cSubmitAs:"PDF",cCharset:"utf-8"});
}
Views
Replies
Total Likes
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"));
}
Views
Replies
Total Likes
Thank you so much!
-Don
Views
Replies
Total Likes
Is there a way to have the required fields verfied that they are populated before the custom email button executes?
Thanks again for your help!
Views
Replies
Total Likes
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
}
Views
Replies
Total Likes
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.ReleasedIntoSystemBy").rawValue !== null) {
vEmail = xfa.resolveNode("#subform[0].#subform[2].Table111[1].Row1.ReleasedIntoSystemBy").rawValue;
}
// Send email
event.target.submitForm({cURL:"mailto: " + vEmail + "?subject=" + vSubject + "&body=" + vBody,cSubmitAs:"PDF",cCharset:"utf-8"});
}
Views
Replies
Total Likes
I got it working - thanks again!
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies