Hello All
As per the subject, what was working in 9 is behaving very differently in X.
Now I understand there have been changes but I cannot decipher how they impact on this script. In X, the button will still work but it launches and sends the email with the PDF attached in one invisible action, whereas it previously opened an email where extra information/attachments could be added. This is particularly important for this forms functionality.
If I open the below script in X (Properties > Actions > Run a JavaScript) it receives errors that disallow it from being saved. It was never an issue in 9. A colleague who is very familiar with scripting cannot diagnose the issue either and his debugging options thinks it fine too. I absolutely hope that someone here has that snippet of information which makes sense of all this new found chaos....
Thanks for looking.
// These are the required fields on the form.
// Populate array with their names.
var RequiredFields = new Array(25);
RequiredFields[0] = '*****';
RequiredFields[1] = '*****';
RequiredFields[2] = '*****';
RequiredFields[3] = '*****';
RequiredFields[4] = '*****';
RequiredFields[5] = '*****';
RequiredFields[6] = '*****';
RequiredFields[7] = '*****';
RequiredFields[8] = '*****';
RequiredFields[9] = '*****';
RequiredFields[10] = '*****';
RequiredFields[11] = '*****';
RequiredFields[12] = '*****';
RequiredFields[13] = '*****';
RequiredFields[14] = '*****';
RequiredFields[15] = '*****';
RequiredFields[16] = '*****';
RequiredFields[17] = '*****';
RequiredFields[18] = '*****';
RequiredFields[19] = '*****';
RequiredFields[20] = '*****';
RequiredFields[21] = '*****';
RequiredFields[22] = '*****';
RequiredFields[23] = '*****';
RequiredFields[24] = '*****';
// These are the alert messages shown when a required field is empty.
// Populate array with messages.
// Make sure there's one message for each required field.
var alertMsg = ' is a required field - Please enter your information';
var bSuccess=true
var emptyTest = /^[\s -]*$/;
var fieldCount = RequiredFields.length
var fld = 0;
for (var i=0; i < fieldCount; i++) {
fld = this.getField(RequiredFields[i]);
if(emptyTest.test(fld.value) ) // if required field is empty
{
bSuccess=false;
app.alert(RequiredFields[i] + alertMsg);
fld.setFocus();
break;
}
}
if(bSuccess) {
var address = ' ';
if (this.getField('OMS').value == '**') {
address = '***@***.***.**';
} else {
address = '***@***.***.**';
}
var subj = this.getField('*****').value + ' - ' + this.getField('*****').value + '*****' + this.getField('*****').value + '*****' + this.getField('*****').value;
var msgBody = 'Blah blah\n\nBlah blah blah.\n\nBlah.';
////message box with instructions to add email addresses
var cResponse = app.alert({
cMsg: 'Blah.\n\nBlah.\n\nBlah email.\nClick NO to go back and continue editing the blah.',
nIcon: 2,
nType: 2,
cTitle: 'Emailing Job Docket'});
// proceed only if response is 'YES'
if (cResponse == 4) {
this.mailDoc({
bUI: false,
cTo: address,
cSubject: subj,
cMsg: msgBody,
cSubmitAs: 'PDF'
});
}
}
You say you're getting errors that "disallow it from being saved." Can you clarify what you mean and post the exact text of the errors you're seeing?