- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2024 06:52 AM
create a ui action to close incident state when all the incident task is cloes complete if any task is not close complete then will not be able to close the state and print a msg please close task incident first?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2024 11:04 AM
Hi @akashsingh20234 ,
I tried your problem in my PDI and I hope this code helps you, Please create UI Action which is client callable and add below code
function incidentClose() {
var state = [];
var gr = new GlideRecord('incident_task');
gr.addQuery('incident', g_form.getUniqueValue());
gr.query();
while (gr.next()) {
state.push(gr.state.toString()); // There are multiple incidnet tasks
}
for (i = 0; i < state.length; i++) {
alert("Inside for = " + state[i]);
if (state[i] != state[i - 1]) {
alert('All the Incident Task Values are not Close Complete ');
} else {
if (state[i] == 3) {
alert("CLosing the Incident bcoz all the Incident task are Close Complete ");
current.state = '7';
current.update();
}
}
}
}
Result
Scenerio 1 : When Incident Task is not close complete
Scenerio 2: When Incident Tasks are close compelte
All the incindet tasks are complete
Please mark my ans correct and helpful if this works for you
Thanks and Regards
Sarthak
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2024 09:57 AM
Hi @akashsingh20234 ,
Please refer the below code :
Please mark my response helpful if it resolves your issue!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2024 11:04 AM
Hi @akashsingh20234 ,
I tried your problem in my PDI and I hope this code helps you, Please create UI Action which is client callable and add below code
function incidentClose() {
var state = [];
var gr = new GlideRecord('incident_task');
gr.addQuery('incident', g_form.getUniqueValue());
gr.query();
while (gr.next()) {
state.push(gr.state.toString()); // There are multiple incidnet tasks
}
for (i = 0; i < state.length; i++) {
alert("Inside for = " + state[i]);
if (state[i] != state[i - 1]) {
alert('All the Incident Task Values are not Close Complete ');
} else {
if (state[i] == 3) {
alert("CLosing the Incident bcoz all the Incident task are Close Complete ");
current.state = '7';
current.update();
}
}
}
}
Result
Scenerio 1 : When Incident Task is not close complete
Scenerio 2: When Incident Tasks are close compelte
All the incindet tasks are complete
Please mark my ans correct and helpful if this works for you
Thanks and Regards
Sarthak