Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


BUTTON SCRIPT WITH A buttonSetCaption for LOCK AND UNLOCK. (ACROBAT DC)

Explorer ,
Aug 18, 2021 Aug 18, 2021

Copy link to clipboard

Copied

Hopefully, I would get the help I seriously need this time around. I need help on the subject matter.

Can someone help me pls!!!!!!!!!!

Thanks.

Views

125

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
Adobe Community Professional ,
Aug 18, 2021 Aug 18, 2021

Copy link to clipboard

Copied

Let me move this to the Acrobat forum for you, which is the appropriate forum for your question.

The Using the Community forum is for help in using the Adobe Support Community forums, not for help with specific programs. Product questions should be posted in the associated product community.

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
Adobe Community Professional ,
Aug 18, 2021 Aug 18, 2021

Copy link to clipboard

Copied

What want lock and unlock?

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
Explorer ,
Aug 18, 2021 Aug 18, 2021

Copy link to clipboard

Copied

Thanks for responding. I would want the form user to access the form fields by the use of a password to access its content. This should be by the click of a button that would request a password.

Thanks

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
Adobe Community Professional ,
Aug 18, 2021 Aug 18, 2021

Copy link to clipboard

Copied

So you want to use the button to prompt the user for a password and if it's the correct one it should "unlock" all the other fields in the file, and when pressed again, it will "lock" them once more?

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
Explorer ,
Aug 18, 2021 Aug 18, 2021

Copy link to clipboard

Copied

Exactly.

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
Adobe Community Professional ,
Aug 18, 2021 Aug 18, 2021

Copy link to clipboard

Copied

You can do it using this code:

 

var lockFields = event.target.buttonGetCaption()=="Lock";
for (var i=0; i<this.numFields; i++) {
	var fname = this.getNthFieldName(i);
	if (event.target.name==fname) continue;
	var f = this.getField(fname);
	if (f==null) continue;
	f.readonly = lockFields;
}
event.target.buttonSetCaption(lockFields ? "Unlock" : "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
Adobe Community Professional ,
Aug 18, 2021 Aug 18, 2021

Copy link to clipboard

Copied

Sorry, forgot the password part... Will add now.

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
Adobe Community Professional ,
Aug 18, 2021 Aug 18, 2021

Copy link to clipboard

Copied

New version, this time with a password to unlock the fields (the correct password in this case is "12345"):

 

var lockFields = event.target.buttonGetCaption()=="Lock";
if (!lockFields) {
	var resp = app.response("Enter the password to unlock the fields:","","");
	if (resp!="12345") {
		app.alert("Invalid password.");
		lockFields = true;
	}
}
for (var i=0; i<this.numFields; i++) {
	var fname = this.getNthFieldName(i);
	if (event.target.name==fname) continue;
	var f = this.getField(fname);
	if (f==null) continue;
	f.readonly = lockFields;
}
event.target.buttonSetCaption(lockFields ? "Unlock" : "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
Explorer ,
Aug 18, 2021 Aug 18, 2021

Copy link to clipboard

Copied

Okey. let me try it and get back to you.

Thanks.

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
Explorer ,
Aug 18, 2021 Aug 18, 2021

Copy link to clipboard

Copied

I just noticed that also.

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
Explorer ,
Aug 18, 2021 Aug 18, 2021

Copy link to clipboard

Copied

It worked like magic. thanks.

One more thing which is very important. i have a reset button which resets an invoice field i wouldn't want to reset except with a password. my form users click a check box to generate the invoice number serially. below is the script in that button.

var svfile = app.alert ("You are about to reset/delete all information on this form. Will you like to continue?", 2, 2);

if (svfile == 2 || svfile ==3) {

app.alert ("You may save a copy before reseting this form.", 1);

} else {

for (var i=0; i<this.numFields; i++) {

var f = this.getField(this.getNthFieldName(i));

if (f.type != "button")

{

f.readonly = false;

}

}
this.resetForm();
}

how do i include this lock and unlock script to  this script with a different password i would only have access to.

Thanks.

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
Adobe Community Professional ,
Aug 18, 2021 Aug 18, 2021

Copy link to clipboard

Copied

Sorry, I don't quite follow... Could you share the file with us?

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
Explorer ,
Aug 18, 2021 Aug 18, 2021

Copy link to clipboard

Copied

Attached is the form. the reset in at the bottom. each time they reset it, the invoiceID start counting from zero which is not appropriate. it results to a lot of clicks to get to the last used invoice number.

The point is that I should only have access to resetting the doc. number. we want the doc. number serially for audit reasons.

Thanks.

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
Adobe Community Professional ,
Aug 18, 2021 Aug 18, 2021

Copy link to clipboard

Copied

If you don't want the field's value to be affected you have two options:

- Change the defaultValue property of the field when you change the value property, so they are always the same.

- Instead of resetting the entire form create an array of all the field names, except for those you don't want to be changed, and pass that as a parameter to resetForm.

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
Adobe Community Professional ,
Aug 18, 2021 Aug 18, 2021

Copy link to clipboard

Copied

I guess there's another option:

- Save the field's value to a variable before resetting, then apply it back to it afterwards.

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
Explorer ,
Aug 18, 2021 Aug 18, 2021

Copy link to clipboard

Copied

I understand for the second option which I already created on the form. but the first and third would work for me even though I don't fully understand it. i would want the form user not to skip a single number by double clicking and as a result asking me for a form reset.

Thanks.

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
Adobe Community Professional ,
Aug 18, 2021 Aug 18, 2021

Copy link to clipboard

Copied

You can do the third option I suggested like this:

 

var invoiceID = this.getField("InvoiceID1").valueAsString;
this.resetForm();
this.getField("InvoiceID1").value = invoiceID;

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
Explorer ,
Aug 18, 2021 Aug 18, 2021

Copy link to clipboard

Copied

Okey.

Sorry I forgot to say that they are invoiceID1 and invoiceID2. How do I add invoiceID2 to the script.invoiceID2 is behind invoiceID1.

Thanks

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
Adobe Community Professional ,
Aug 18, 2021 Aug 18, 2021

Copy link to clipboard

Copied

Same thing:

 

var invoiceID1 = this.getField("InvoiceID1").valueAsString;
var invoiceID2 = this.getField("InvoiceID2").valueAsString;
this.resetForm();
this.getField("InvoiceID1").value = invoiceID1;
this.getField("InvoiceID2").value = invoiceID2;

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
Explorer ,
Aug 18, 2021 Aug 18, 2021

Copy link to clipboard

Copied

LATEST

That should be all for now. Thanks for your help. I really appreciate it.

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