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

Dynamic Stamp with multiple input from option buttons to be filled into the checkbox!

New Here ,
Jul 04, 2016 Jul 04, 2016

I'm trying the below code to get a stamp with the multiple input. Based on the selection of option buttons, I require the stamp to be updated. I'm unable to find the error. Could someone help pl.

TOPICS
Acrobat SDK and JavaScript , Windows
5.6K
Translate
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

correct answers 1 Correct answer

Community Expert , Jul 06, 2016 Jul 06, 2016

OK, that's fine.

I think the issue is that you defined the dialog object after the code where you're calling it. You should move the definition of DiaBox to the top of the code.

Translate
New Here ,
Jul 04, 2016 Jul 04, 2016

if(event.source.forReal && (event.source.stampName == "#pfP__PjJ7SwG7RRWsGspWA"))

{

if ("ok" == app.execDialog(DiaBox))

{

this.getField("Approved - Submit Final Copies").checkThisBox(0, DiaBox.bChk1);

this.getField("Approved as commented - Resubmit").checkThisBox(0, DiaBox.bChk2);

this.getField("Not Approved - Resubmit").checkThisBox(0, DiaBox.bChk3);

this.getField("Cleared for Manufacture").checkThisBox(0, DiaBox.bChk4);

this.getField("For Information").checkThisBox(0, DiaBox.bChk5);

var cMsg = DiaBox.byName;

event.value = "Remarks # " + cMsg;

event.source.source.info.exhibit = cMsg;

}

}

var DiaBox =

{

result:"cancel",

DoDialog: function(){return app.execDialog(this);},

bChk1:true,

bChk2:false,

bChk3:false,

bChk4:false,

bChk5:false,

stredt1:"",

initialize: function(dialog)

{

var dlgInit =

{

"Chk1": this.bChk1,

"Chk2": this.bChk2,

"Chk3": this.bChk3,

"Chk4": this.bChk4,

"Chk5": this.bChk5,

"Name": this.stredt1,

};

dialog.load(dlgInit);

},

commit: function(dialog)

{

var oRslt = dialog.store();

this.bChk1 = oRslt["Chk1"];

this.bChk2 = oRslt["Chk2"];

this.bChk3 = oRslt["Chk3"];

this.bChk4 = oRslt["Chk4"];

this.bChk5 = oRslt["Chk5"];

this.byName = oRslt["Name"];

},

description:

{

name: "Stamp",

elements:

[

{

type: "view", elements:

[

{

type: "view",

char_height: 10,

elements:

[

{

type: "static_text",

item_id: "stat",

name: "Please select the review category:",

width: 152,

height: 23,

char_width: 15,

alignment: "align_fill",

font: "dialog",

},

{

type: "radio",

item_id: "Chk1",

group_id: "rado",

name: "Approved - Submit Final Copies",

},

{

type: "radio",

item_id: "Chk2",

group_id: "rado",

name: "Approved as commented - Resubmit",

},

{

type: "radio",

item_id: "Chk3",

group_id: "rado",

name: "Not Approved - Resubmit",

},

{

type: "radio",

item_id: "Chk4",

group_id: "rado",

name: "Cleared for Manufacture",

},

{

type: "radio",

item_id: "Chk5",

group_id: "rado",

name: "For Information",

},

{ type: "edit_text",

item_id: "Name",

height: 23,

char_width: 20,

char_height: 10,

alignment: "align_center",

name: "Enter Initials",

}

]

},

{

type: "ok_cancel",

},

]

},

]

}

};

Translate
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 ,
Jul 05, 2016 Jul 05, 2016

The above code is working only if my source stamp file is open first before the pdf in which I want to stamp is open. if the source stamp file is not open, the pop up box for input is not opening! it directly applies the seal on PDF without taking the user input

Translate
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 05, 2016 Jul 05, 2016

Where did you place this code? Are you sure you're using the correct stampName value?

Translate
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 ,
Jul 05, 2016 Jul 05, 2016

Yes! I have rechecked the stamp name. and I have placed the code in custom calculation script of one text box... textbox2.

Translate
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 05, 2016 Jul 05, 2016

Sorry for insisting, but this is crucial... How did you check the stamp name?

Translate
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 ,
Jul 05, 2016 Jul 05, 2016

I placed the stamp on PDF and ... in console I gave the    this.selectedAnnots[0].AP  ....

this is the stamp name

#pfP__PjJ7SwG7RRWsGspWA ...

Translate
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 06, 2016 Jul 06, 2016

OK, that's fine.

I think the issue is that you defined the dialog object after the code where you're calling it. You should move the definition of DiaBox to the top of the code.

Translate
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 ,
Jul 10, 2016 Jul 10, 2016

Thank you soo much, it worked when I changed the order!!! cool

Translate
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 ,
Jul 10, 2016 Jul 10, 2016

So the final code that worked....

var DiaBox =

{

result:"cancel",

DoDialog: function(){return app.execDialog(this);},

bChk1:false,

bChk2:false,

bChk3:false,

bChk4:false,

bChk5:false,

stredt1:"",

initialize: function(dialog)

{

var dlgInit =

{

"Opt1": this.bChk1,

"Opt2": this.bChk2,

"Opt3": this.bChk3,

"Opt4": this.bChk4,

"Opt5": this.bChk5,

"Name": this.stredt1,

};

dialog.load(dlgInit);

},

commit: function(dialog)

{

var oRslt = dialog.store();

this.bChk1 = oRslt["Opt1"];

this.bChk2 = oRslt["Opt2"];

this.bChk3 = oRslt["Opt3"];

this.bChk4 = oRslt["Opt4"];

this.bChk5 = oRslt["Opt5"];

this.byName = oRslt["Name"];

},

description:

{

name: "Stamp",

elements:

[

{

type: "view",

elements:

[

{

type: "view",

char_height: 10,

elements:

[

{

type: "static_text",

item_id: "stat",

name: "Please select the review category:",

width: 152,

height: 23,

char_width: 15,

alignment: "align_fill",

font: "dialog",

},

{

type: "radio",

item_id: "Opt1",

group_id: "rado",

name: "Approved - Submit Final Copies",

},

{

type: "radio",

item_id: "Opt2",

group_id: "rado",

name: "Approved as commented - Resubmit",

},

{

type: "radio",

item_id: "Opt3",

group_id: "rado",

name: "Not Approved - Resubmit",

},

{

type: "radio",

item_id: "Opt4",

group_id: "rado",

name: "Cleared for Manufacture",

},

{

type: "radio",

item_id: "Opt5",

group_id: "rado",

name: "For Information",

},

{

type: "edit_text",

item_id: "Name",

height: 35,

char_width: 20,

char_height: 10,

alignment: "align_center",

name: "Enter Comments",

}

]

},

{

type: "gap",    //Add a small vertical gap between

height: 10      //..radio fields and buttons

},

{

type: "ok_cancel",

},

]

},

]

}

};

if(event.source.forReal && (event.source.stampName == "#pfP__PjJ7SwG7RRWsGspWA"))

{

if ("ok" == app.execDialog(DiaBox))

{

this.getField("Text3").value = ((!identity.name || identity.loginName != (event.source.source || this).Collab.user) ? (event.source.source || this).Collab.user : identity.name);

this.getField("Text1").value = util.printd("h:MM tt,dd-mmm-yyyy", new Date());

this.getField("cbx1").checkThisBox(0, DiaBox.bChk1);

this.getField("cbx2").checkThisBox(0, DiaBox.bChk2);

this.getField("cbx3").checkThisBox(0, DiaBox.bChk3);

this.getField("cbx4").checkThisBox(0, DiaBox.bChk4);

this.getField("cbx5").checkThisBox(0, DiaBox.bChk5);

console.println("Success1");

var cMsg = DiaBox.byName;

event.value = "Comment # " + cMsg;

event.source.source.info.exhibit = cMsg;

}

}

Translate
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 ,
Mar 13, 2018 Mar 13, 2018

I tried to follow this solution but mine doesn't populate the radio button selection onto the actual stamp. It will be print the info on By: and Date: but the rest will not populated. Please help. My code is  below.

var DiaBox =

{

result:"cancel",

DoDialog: function()

{return app.execDialog(this);

},

bChk1:false,

bChk2:false,

bChk3:false,

bChk4:false,

stredt1:"",

initialize: function(dialog)

{

var dlgInit =

{

"Choice1": this.bChk1,

"Choice2": this.bChk2,

"Choice3": this.bChk3,

"Choice4": this.bChk4,

"Comment": this.stredt1,

};

dialog.load(dlgInit);

},

commit: function(dialog)

{

var results = dialog.store();

this.bChk1 = results["Choice1"];

this.bChk2 = results["Choice2"];

this.bChk3 = results["Choice3"];

this.bChk4 = results["Choice4"];

this.byName = results["Name"];

},

description:

{

name: "stamp1",

elements:

[

{

type: "view",

elements:

[

{

type: "view",

char_height: 10,

elements:

[

{

type: "static_text",

item_id: "stat",

name: "Please select the review category:",

width: 152,

height: 23,

char_width: 15,

alignment: "align_fill",

font: "dialog",

},

{

type: "radio",

item_id: "Choice1",

group_id: "Group1",

name: "Reviewed",

},

{

type: "radio",

item_id: "Choice2",

group_id: "Group1",

name: "Reviewed with changes noted",

},

{

type: "radio",

item_id: "Choice3",

group_id: "Group1",

name: "Revise and Resubmit",

},

{

type: "radio",

item_id: "Choice4",

group_id: "Group1",

name: "Rejected",

},

{

type: "edit_text",

item_id: "Name",

height: 35,

char_width: 20,

char_height: 10,

alignment: "align_center",

name: "Enter Comments",

}

]

},

{

type: "gap",    //Add a small vertical gap between

height: 10      //..radio fields and buttons

},

{

type: "ok_cancel",

},

]

},

]

}

};

if(event.source.forReal && (event.source.stampName == "#stamp1"))

{

if ("ok" == app.execDialog(DiaBox))

{

this.getField("By").value = ((!identity.name || identity.loginName != (event.source.source || this).Collab.user) ? (event.source.source || this).Collab.user : identity.name);

this.getField("Date").value = util.printd("h:MM tt,dd-mmm-yyyy", new Date());

this.getField("Comment").value = results["Name"];

this.getField("rado1").checkThisBox(0, DiaBox.bChk1);

this.getField("cbx2").checkThisBox(0, DiaBox.bChk2);

this.getField("cbx3").checkThisBox(0, DiaBox.bChk3);

this.getField("cbx4").checkThisBox(0, DiaBox.bChk4);

console.println("Stamp Name: " + event.source.stampName);

var cMsg = DiaBox.byName;

event.value = "Comment # " + cMsg;

event.source.source.info.exhibit = cMsg;

}

}

Translate
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 ,
Mar 13, 2018 Mar 13, 2018

The item ID can only be four letters long. You are using for example "Choice4" - this will not work.

Translate
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 ,
Mar 13, 2018 Mar 13, 2018

I edited it and changed it to "Btn1" and so on. Still not transferring the selection from the dialog box onto the stamp

var DiaBox =

{

result:"cancel",

DoDialog: function()

{return app.execDialog(this);

},

bChk1:false,

bChk2:false,

bChk3:false,

bChk4:false,

stredt1:"",

initialize: function(dialog)

{

var dlgInit =

{

"Btn1": this.bChk1,

"Btn2": this.bChk2,

"Btn3": this.bChk3,

"Btn4": this.bChk4,

"Name": this.stredt1,

};

dialog.load(dlgInit);

},

commit: function(dialog)

{

var results = dialog.store();

this.bChk1 = results["Btn1"];

this.bChk2 = results["Btn2"];

this.bChk3 = results["Btn3"];

this.bChk4 = results["Btn4"];

this.byName = results["Name"];

},

description:

{

name: "stamp1",

elements:

[

{

type: "view",

elements:

[

{

type: "view",

char_height: 10,

elements:

[

{

type: "static_text",

item_id: "stat",

name: "Please select the review category:",

width: 152,

height: 23,

char_width: 15,

alignment: "align_fill",

font: "dialog",

},

{

type: "radio",

item_id: "Btn1",

group_id: "Group1",

name: "Reviewed",

},

{

type: "radio",

item_id: "Btn2",

group_id: "Group1",

name: "Reviewed with changes noted",

},

{

type: "radio",

item_id: "Btn3",

group_id: "Group1",

name: "Revise and Resubmit",

},

{

type: "radio",

item_id: "Btn4",

group_id: "Group1",

name: "Rejected",

},

{

type: "edit_text",

item_id: "Name",

height: 35,

char_width: 20,

char_height: 10,

alignment: "align_center",

name: "Enter Comments",

}

]

},

{

type: "gap",    //Add a small vertical gap between

height: 10      //..radio fields and buttons

},

{

type: "ok_cancel",

},

]

},

]

}

};

if(event.source.forReal && (event.source.stampName == "#stamp1"))

{

if ("ok" == app.execDialog(DiaBox))

{

this.getField("By").value = ((!identity.name || identity.loginName != (event.source.source || this).Collab.user) ? (event.source.source || this).Collab.user : identity.name);

this.getField("Date").value = util.printd("h:MM tt,dd-mmm-yyyy", new Date());

this.getField("Comment").value = this.byName;

this.getField("cbx1").checkThisBox(0, DiaBox.bChk1);

this.getField("cbx2").checkThisBox(0, DiaBox.bChk2);

this.getField("cbx3").checkThisBox(0, DiaBox.bChk3);

this.getField("cbx4").checkThisBox(0, DiaBox.bChk4);

console.println("Stamp Name: " + event.source.stampName);

var cMsg = DiaBox.byName;

event.value = "Name " + cMsg;

event.source.source.info.exhibit = cMsg;

}

}

Translate
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 ,
Mar 13, 2018 Mar 13, 2018

Are you getting any error messages on the JavaScript console?

Translate
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
LEGEND ,
Jul 05, 2016 Jul 05, 2016

There is only one stamp name , that is one used by JavaScript, and then there is the stamp user label that one sees displayed by the UI.

Dynamic stamp secrets using JavaScript and Acrobat XI by Thom Parker

Translate
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 ,
Mar 13, 2018 Mar 13, 2018

I have an error :

TypeError: this.getField(...) is null

115:App:Calculate

Translate
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 ,
Mar 13, 2018 Mar 13, 2018

Check your line #115, you are trying to reference a field that does not

exist.

Translate
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 ,
Mar 14, 2018 Mar 14, 2018

Okay, I've fixed the error on line #115 but now I have these errors ( see below) . and line 125 is this this.getField("Btn1").checkThisBox(0, DiaBox.bChk1);

Btn 1 thru Btn4 is the item_id of each of my radio button

TypeError: this.getField(...) is null

125:App:Calculate

TypeError: event.source is null

116:Field:Calculate

TypeError: this.getField(...) is null

125:App:Calculate

TypeError: event.source is null

116:Field:Calculate

TypeError: event.source is null

116:Field:Calculate

Translate
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 ,
Mar 14, 2018 Mar 14, 2018

"stamp1" can't be the name of your stamp. You need to find out the internal AP name.

Also, change this line:

if (event.source.forReal && (event.source.stampName == "#stamp1")) {

to:

if (event.source && event.source.forReal && (event.source.stampName == "#stamp1")) {

Translate
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 ,
Mar 14, 2018 Mar 14, 2018

What is an internal AP name mean?

Translate
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 ,
Mar 14, 2018 Mar 14, 2018

It's a property of the stamp. To find it out apply your stamp to a page, select it with the mouse, and then run this code from the JS Console:

this.selectedAnnots[0].AP

This is the value you need to use as the stampName in your code.

Translate
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 ,
Mar 14, 2018 Mar 14, 2018

Take a look at this tutorial, it explains how you would use the AP property: https://acrobatusers.com/tutorials/dynamic_stamp_secrets

Translate
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 ,
Mar 14, 2018 Mar 14, 2018

the name of my stamp is #stamp1 because I named it that way.

Translate
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 ,
Mar 14, 2018 Mar 14, 2018

My problem or error is this statement this.getField("Btn1").checkThisBox(0,DiaBox.bChk1);

it's giving me an error of NULL and I don't understand why

Translate
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 ,
Mar 14, 2018 Mar 14, 2018

That means there's no field with that name in your file.

Translate
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