Unable to rename action button from value of app.response.

Explorer ,
Aug 13, 2019 Aug 13, 2019

Copy link to clipboard

Copied

I am trying to rename the action button using the response given from the "app.response" entry. This value will be used not only to rename the action button but will also be used to fill in a form field on the spawned document.

I am using a windows based computer - the code I have written works except I can't figure out  how use the variable generated by the user response to change the button label and to be used to populate other fields in the document.

// If button is Clicked and the hidden check box is not checked - the Analyzer1 check-off pages will be spawned;

var cb2 = this.getField("CB2").value;

// Assign Templates to be spawned a variable so they may be recalled;

var a1a = this.getTemplate("Analyzer1A");

var a1b = this.getTemplate("Analyzer1B");

var a1c = this.getTemplate("Analyzer1C");

var a1d = this.getTemplate("Analyzer1D");

  if (cb2 != "Yes"){

var resp1 = app.response(" Enter The Analyzer Serial Number.");

if ((resp1 != null)||(resp1 !="")){

this.getField("Anal1").buttonSetCaption(resp1);

a1a.spawn({nPage:this.numPages-1,bRename:false,bOverlay:false});

a1b.spawn({nPage:this.numPages-1,bRename:false,bOverlay:false});

a1c.spawn({nPage:this.numPages-1,bRename:false,bOverlay:false});

a1d.spawn({nPage:this.numPages-1,bRename:false,bOverlay:false});

this.getField("CB2").checkThisBox(0,true);

}}

else{

app.alert ("Documentation For Analyzer 1 Has Already Been Created.");

}

TOPICS
Acrobat SDK and JavaScript, Windows

Views

59

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
Most Valuable Participant ,
Aug 13, 2019 Aug 13, 2019

Copy link to clipboard

Copied

To change the label of a button field use the buttonSetCaption method.

For example:

this.getField("MyButton").buttonSetCaption("New Label Text");

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 13, 2019 Aug 13, 2019

Copy link to clipboard

Copied

Try67,

Thank You for your quick response! I have no problem changing the label if I want to set it to specific text like "Assigned". The problem is I need it to rename the button field from the user input obtained from the app.response. It should be easy peasy because it is saved into a memory variable, but nothing I have tried works. It will either fill the field with "resp1" or "Undefined".

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
Most Valuable Participant ,
Aug 13, 2019 Aug 13, 2019

Copy link to clipboard

Copied

It works exactly the same. Simply apply the variable directly as the parameter of the function, instead of a literal string.

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
Most Valuable Participant ,
Aug 13, 2019 Aug 13, 2019

Copy link to clipboard

Copied

LATEST

A little look at this line:

if ((resp1 != null)||(resp1 !=""))

Saying if response is NOT null (test 1)

OR if the response is NOT an empty string (test 2)

If the response is null this is true, because of test 2

If the response is an empty string this is true because of test 1

If the response is anything else this is true because of BOTH tests.

This means your "else" part will never be seen.

I am guessing you actually wanted an &&, though it's not always a good idea to guess what someone else wants.

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