On-change Client script issue in ServiceNow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2023 11:02 PM
Hi All,
I wrote one client script on change based on the if condition status could not be change & its will through info/error message & status will back to "in progress" state instead of changing any status.
But for when we select "Resolved" , inside the if loop is not executed & alert message not executed.
Regarding this request instead of adding this condition : if (tickettype == "871c5d5e87b3e9140811646e8bbb3530" && approv == "not requested" && g_form.getValue("state") != "In progress") to if (tickettype == "871c5d5e87b3e9140811646e8bbb3530" && approv == "not requested" && g_form.getValue("state") == "Resolved") not working properly after if loop, within if loop alert not display. could you please help me on that.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2023 11:09 PM
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue == '') {
return;
}
var tickettype = g_form.getValue('type');
var approv = g_form.getValue('approval');
if (tickettype == "871c5d5e87b3e9140811646e8bbb3530" && approv == "not requested" && g_form.getValue("state") == "Resolved") {
alert("Hello world");
g_form.addErrorMessage("Status could not be changed");
g_form.setValue("state", "In progress");
alert("Status set to 'In progress'");
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2023 11:54 PM
Hi @Harish Bainsla ,
I used similar code but from if condition it is not working. Not get any alert() from inside if loop.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2023 12:13 AM
please put backend resolved field value
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2023 11:38 PM
You are storing value in var ticket and in if condition using tickettype? Try changing it to ticket in if condtion?