Question
why does this code works with Nitro Pro but not with Adobe?
function getFileName() {
var sequenceNumber = this.getField("Form1.0").value;
var fileName = global.documentNum + "_" + sequenceNumber + ".pdf";
return fileName;
}
function getFilePath() {
var userName = "GAC_Line";
var path = "/c/users/" + userName + "/desktop/safe work permits/" + getFileName();
return path;
}
function validate() {
var fieldNames = [];
var displayFieldNames = [];
var regexEmpty = /^\s*$/;
const fieldCount = 24; // increment to add more fields
for(var i = 0; i < fieldCount; i++) {
var field = this.getField("Form1." + i);
if(regexEmpty.test(this.getField(field.name).value) || field.valueAsString == field.defaultValue) {
fieldNames.push(field.name);
displayFieldNames.push(field.userName);
}
}
if(fieldNames.length > 0) {
var field_sp = fieldNames.length == 1 ? "field" : "fields";
app.alert("Please complete the following " + field_sp + ":\n\n" + displayFieldNames.join("\n"));
getField(displayFieldNames[0]).setFocus();
} else {
this.saveAs(getFilePath());
app.alert("Form " + getFileName() + " has been saved to the Safe Work Permits folder. The print dialog window will now open.", 3);
this.print();
}
}
validate();
