• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers

Variable will not change value to add to spawned pages

Explorer ,
Jul 21, 2020 Jul 21, 2020

Copy link to clipboard

Copied

I have form that assigns analyzers when the mouse up action occurs on the form. User will enter the serial number of the analyzers and the appropriate forms are spawned. I had to add a feature to allow the user to change the serial Number in case they make a mistake or the Analyzer fails in the field. I opted to delete the spawned pages and recall them again using the new variable value to add the serial number on the newly spawned forms. Everything works as should and no errors are logged in the debugger except the the old serial number is added to the newly spawned forms. The portion of code to assign the new value to the variable is highlighted in red. I have tried everything I could think of  and have serched online for countless hours. Any help would be greatly appreiated. 

The code I wrote as follows:

// 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;
var b1 = this.getField("Anal1");

// 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({cQuestion:"Enter The Analyzer Serial Number.", cTitle:"H2S Analyzer Documentation", cLabel:"H2S Analyzer #:"});

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

b1.buttonSetCaption("Analyzer 1");
}
else{

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

b1.buttonSetCaption(resp1);
}}

else{

var nser1 = app.alert ({cMsg:"Documentation For Analyzer 1 Has Already Been Created.\n\n" + "Do you wish to Change the Analyzer Serial Number?",nIcon:2,nType:2 });
// User Pressed Yes
if(nser1 === 4){
var resp1a = app.response({cQuestion:"Enter The New Analyzer Serial Number.", cTitle:"H2S Analyzer Documentation", cLabel:"New H2S Analyzer Serial #:"});
if ((resp1a === null)||(resp1a ==="")){
b1.buttonSetCaption(resp1);
}
else{
b1.buttonSetCaption(resp1a);
resp1 = resp1a;
this.deletePages({nStart:4, nEnd:7});

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});
}
}}

TOPICS
Acrobat SDK and JavaScript

Views

61

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 ,
Jul 22, 2020 Jul 22, 2020

Copy link to clipboard

Copied

You're not using the resp1 variable anywhere after the highlighted line, so what effect do you think changing its value will have?

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 ,
Jul 22, 2020 Jul 22, 2020

Copy link to clipboard

Copied

The variable resp1 is used to populate cerain fields in the newly spawned pages, other fields in the documents and to update the database.

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 ,
Jul 22, 2020 Jul 22, 2020

Copy link to clipboard

Copied

LATEST

It doesn't do that in the code you posted above. If there's more to it, please post all of 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