Dynamic Stamp JavsScript HELP
Hello Community, as you may already see I have no Tech knowledge, but using AI was able to have some what of a code that works.
"
if ((event.source.forReal) && (event.source.stampName == "#QAStamp")) {
// Define the messages for each check box
var messages = [
"NIST Traceable:",
"Lab ID:",
"Calibration Standard:",
"Calibration Status/Re-calibration Date:",
"Actual Results:",
"Notes of Adjustment:",
"Parker Tolerance Used:",
"Parker Tolerance Stated:"
];
// Loop through each check box and prompt the user to check or uncheck
for (var i = 1; i <= 8; i++) {
var checkBoxValue = app.response({
cQuestion: messages[i - 1] + " (Yes/No):",
cTitle: "Check Box Selection",
cDefault: "No"
});
this.getField("Check Box" + i).value = (checkBoxValue.toLowerCase() === "yes") ? "Yes" : "Off";
}
// Prompt user for initials
this.getField("Initials").value = app.response("Initials: ");
}"
but I do not like the behavior, since if you run it you can see the dialogue boxes appear individually and the user has to write "YES" every time.
I try having it modify, but it does not run, I gave the permits and all, but it is my work PC
"if ((event.source.forReal) && (event.source.stampName == "#QAStamp")) {
// Create a custom dialog box
var theDialog = {
initialize: function(dialog) {
dialog.load({
"Check Box1": "Off",
"Check Box2": "Off",
"Check Box3": "Off",
"Check Box4": "Off",
"Check Box5": "Off",
"Check Box6": "Off",
"Check Box7": "Off",
"Check Box8": "Off",
"Initials": "",
"Date": util.printd("mm/dd/yyyy", new Date())
});
},
commit: function(dialog) {
var data = dialog.store();
for (var i = 1; i <= 8; i++) {
event.target.getField("Check Box" + i).value = data["Check Box" + i];
}
event.target.getField("Initials").value = data.Initials;
event.target.getField("Date_af_date").value = data.Date;
},
description: {
name: "Check Box Selection",
elements: [
{ type: "checkbox", item_id: "Check Box1", name: "NIST Traceable" },
{ type: "checkbox", item_id: "Check Box2", name: "Lab ID" },
{ type: "checkbox", item_id: "Check Box3", name: "Calibration Standard" },
{ type: "checkbox", item_id: "Check Box4", name: "Calibration Status/Re-calibration Date" },
{ type: "checkbox", item_id: "Check Box5", name: "Actual Results" },
{ type: "checkbox", item_id: "Check Box6", name: "Notes of Adjustment" },
{ type: "checkbox", item_id: "Check Box7", name: "Parker Tolerance Used" },
{ type: "checkbox", item_id: "Check Box8", name: "Parker Tolerance Stated" },
{ type: "static_text", item_id: "spacer", name: "ENGINEERING YOUR SUCCESS" },
{ type: "edit_text", item_id: "Initials", name: "Initials" },
{ type: "edit_text", item_id: "Date", name: "Date" },
{ type: "ok_cancel_group" }
]
}
};
// Display the dialog box
var result = app.execDialog(theDialog);
if (result === "ok") {
theDialog.commit.call(this, theDialog);
}
}"
