How to program button to execute sequence of commands
Not sure if this is even possible but here goes...
I would like to program a button for a user to push in order to closeout their form and ready it for processing. The sequence of events I would like would be as follows:
1) Check that all required fields have been completed; if not, allow user to go back and complete missing fields
After all required fields have been completed...
2) Set all fields to read only
3) Add three fields
4) Execute menu item Save As
5) App Alert informing them that their document is ready
I think I have the pieces for each step, I just don't know how (or if it's even possible) to join all these things together. Any help would be appreciated.
Checking required fields:
var emptyFields = [];
for (var i=0; i<this.numFields; i++) {
var f= this.getField(this.getNthFieldName(i));
if (f!=null && f.type!="button" && f.required && f.display==display.visible) {
if (f.valueAsString==f.defaultValue) {
f.strokeColor = color.red;
emptyFields.push(f.name);
} else {
f.strokeColor = color.transparent;
}
}
}
if (emptyFields.length>0) {
app.alert({cMsg:"YOU MUST COMPLETE THE FOLLOWING SECTIONS:\n" + emptyFields.join("\n"),nIcon:0,cTitle:"Required Information Missing"});
Setting all fields to read only:
var oField;
for (var i = 0; i < this.numFields; i++) {
oField = this.getField(this.getNthFieldName(i)).readonly = true;
Add three fields:
this.addField("TextField1", "text", 0, [107,205,198,191]);
this.addField("TextField2", "text", 0, [260,205,365,191]);
this.addField("TextField3", "text", 0, [440,205,500,191]);
Executing menu item Save As:
app.execMenuItem("SaveAs");
App Alert:
app.alert({cMsg:"Your form has been saved successfully and is ready for DocuSign submission.",nIcon:3,nType:0,cTitle:"Finished"});