Skip to main content
Inspiring
August 13, 2019
Question

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

  • August 13, 2019
  • 1 reply
  • 407 views

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.");

}

This topic has been closed for replies.

1 reply

try67
Community Expert
Community Expert
August 13, 2019

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

For example:

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

DuquetteAuthor
Inspiring
August 13, 2019

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

try67
Community Expert
Community Expert
August 13, 2019

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