Customizing Form Field Lock Button for Multiple Functions

New Here ,
Sep 10, 2022 Sep 10, 2022

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:

  1.  Can I set the Javascript to lock the fields only once the document has been saved, instead of simultaneously?
  2.  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:

  1. 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. 

TOPICS
Create PDFs , How to , JavaScript , PDF forms

Views

63

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 10, 2022 Sep 10, 2022

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.

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 11, 2022 Sep 11, 2022

Copy link to clipboard

Copied

Thank you. What condition should I add to save before it triggers the lock? 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 11, 2022 Sep 11, 2022

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. 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 11, 2022 Sep 11, 2022

Copy link to clipboard

Copied

LATEST

Lock the fields only when nButton is 4.

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 10, 2022 Sep 10, 2022

Copy link to clipboard

Copied

And I should clarify. I'm asking if it's possible, and if so, how to do it. Thankyou!!

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 10, 2022 Sep 10, 2022

Copy link to clipboard

Copied

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines