Skip to main content
arunas36741820
Participating Frequently
July 5, 2016
Answered

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

  • July 5, 2016
  • 12 replies
  • 5384 views

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.

This topic has been closed for replies.
Correct answer try67

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

this is the stamp name

#pfP__PjJ7SwG7RRWsGspWA ...


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.

12 replies

Participating Frequently
March 14, 2018

FINALLY!!! Here is the final code that works for me.

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"];

    this.stredt1 = results["Name"];

},

    description:

{

    name: "#stamp1",

    elements:

    [

{

    type: "view",

    elements:

[

{

    type: "view",

    char_height: 10,

    elements:

    [

{

    type: "static_text",

    item_id: "stat",

    name: "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: "static_text",

    item_id: "stat2",

    name: "ENTER REJECTION COMMENTS:",

    width: 152,

    height: 23,

    char_width: 15,

    alignment: "align_fill",

    font: "dialog",

},

{

    type: "edit_text",

    item_id: "Name",

    height: 35,

    char_width: 20,

    char_height: 10,

    alignment: "align_center",

    name: "Comments",

}

]

},

{

    type: "ok_cancel",

},

]

},

]

}

};

this.resetForm();

if (event.source && 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 = DiaBox.stredt1;

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

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

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

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

   

    var cMsg = this.stredt1;

    event.value = cMsg;

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

}

}

meriçg75308842
Participant
March 14, 2018

Can you try that

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: kas geliştirme "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;

}

}

Participating Frequently
March 14, 2018

It is only recognizing the first radio button no matter which button I select, it will only check the first radio button

Participating Frequently
March 14, 2018

It didn't work.

Participating Frequently
March 14, 2018

sorry, I have another problem. How do I reset the check mark every time the stamp is applied. Right now once the first selection was checked every time I re-apply the stamp it is defaulted to the first selection that I had made (

try67
Community Expert
Community Expert
March 14, 2018

After this line:

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

Add this:

this.resetForm();

Participating Frequently
March 14, 2018

I figured it out! YES!!!

Participating Frequently
March 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

try67
Community Expert
Community Expert
March 14, 2018

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

Participating Frequently
March 14, 2018

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

Participating Frequently
March 14, 2018

What is an internal AP name mean?

try67
Community Expert
Community Expert
March 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.

Participating Frequently
March 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

try67
Community Expert
Community Expert
March 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")) {