Customizing Form Field Lock Button for Multiple Functions
Copy link to clipboard
Copied
I have a lock button with the following Javascript applied:
var nButton = app.alert({
cMsg: "Do you want to lock down and save this document?",
cTitle: "Form lockdown",
nIcon: 2, nType: 2});
if ( nButton == 4 )
app.execMenuItem("SaveAs");
var fieldsToSkip = ["Client Signature 1", "Client Signature 2", "Client Name 1", "Client Name 2"];
for (var i=0; i<this.numFields; i++) {
var fname = this.getNthFieldName(i);
if (fieldsToSkip.indexOf(fname)!=-1) continue;
var f = this.getField(fname);
if (f==null) continue;
f.readonly = true;
}
When the button is clicked, it prompts to save, however the locking happens immidiatly even if you do not save, meaning if you accidently click the button, all of the fields have been locked. So my first question is:
- Can I set the Javascript to lock the fields only once the document has been saved, instead of simultaneously?
- Can the javascript automatically append "_LOCKED" to the file name when saving?
It was also asked if the button could complete multiple functions. Right now when you click it, it locks all of the fields except [""Client Signature 1", "Client Signature 2", "Client Name 1", "Client Name 2"] where a client is supposed to sign and date and then becomes a readonly button. The question i've been asked is:
- Once initially locked, the button could remain functional, and when clicked again, lock those fields which previously didn't get locked, THEN become readonly.
I have limited javascript knowledge so your help is greatly appreciated.
Copy link to clipboard
Copied
1. Yes, you can move that code to the file's Will Save event, but you will need to add some condition to it, to only do so after the Lock button has been clicked, otherwise they will be locked each time you saved the file.
2. Yes, but you will need to install a .js script file on the local computer of each user.
Copy link to clipboard
Copied
Thank you. What condition should I add to save before it triggers the lock?
Copy link to clipboard
Copied
My biggest question/concern is setting the javascript for this lock button so that the form fields are only locked if they click "yes" on the appalert. If they click "no", I dont want anything to lock/the process to be cancelled. With the way it's coded right now, the lock applies if you click "yes" or "no" on the appalert but the save as action only applies with "yes". I want BOTH to only apply with "yes". Hope this is clear.
Copy link to clipboard
Copied
Lock the fields only when nButton is 4.
Copy link to clipboard
Copied
And I should clarify. I'm asking if it's possible, and if so, how to do it. Thankyou!!
Copy link to clipboard
Copied

