I am trying to build a dynamic stamp that has a dropdown menu in the dialog box that pops up when you place the stamp. The dropdown menu should have the following text: "AS BUILT", "CIRCUIT CHECK", "DESIGN CHECK"...ect. When the user makes their selection and clicks OK that value should be added to the stampText field on the stamp.
I was able to get the dropdown menu to appear in the dialog box, but no values are selectable. How can I get the dropdown menu to populate with the desired text? also how can I add the selection to the stamp? If I can get this to work I can replace 10+ stamps with this dynamic stamp. Here is my javascript so far
Code: Select all
var dialog = {
stampTextValue: "AS BUILT", // Default value
stampTextOptions: ([
"AS BUILT",
"CIRCUIT CHECK",
"DESIGN CHECK",
]),
// initialize: function (dialog) {
// var stampText = dialog.store()["stampText"];
// console.println(this.stampTextValue);
// dialog.load({"stampText": this.stampTextValue});
// },
// commit: function (dialog) { // called when OK pressed
// var results = dialog.store();
// this.stampTextValue = results["stampText"]; // Capture the selected value
// },
description: {
name: "Dropdown Menu Test", // Dialog box title
elements: [
{
type: "view",
elements: [
{
name: "Select the thing: ",
type: "static_text",
},
{
item_id: "stmp",
type: "popup",
options: this.stampTextOptions, // Populate dropdown with options
value: this.stampTextValue, // Set default value here
width: 190,
},
{
type: "ok_cancel",
ok_name: "Go!",
cancel_name: "Cancel"
},
]
},
]
}
};
if(event.source.forReal && (event.source.stampName == "#q65hv997#7_NNA29eC9sC0")) {
if ("ok" == app.execDialog(dialog)) {
var stampTextField = this.getField("stampText");
if (stampTextField !== null) {
stampTextField.value = dialog.stampTextValue; // Update the field with the selected value
} else {
console.println("Error: stampText field not found.");
}
}
}