- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2023 06:49 PM - edited 10-04-2023 06:50 PM
Hi Guys, I have a ask where Incident 'State' and 'Substate' values (Choice type) has to change based on the custom field 'u_task_opinion' value (String type). Please suggest how to make this possible using a function or so. Thanks.
1. Incident state will have substate values only when state is 'In Progress".
2. State value should remain same for some values of 'u_task_opinion'.
Eg: If ('u_task_opinion' == 'Make'){
incident.state = 'New';
} else if ('u_task_opinion' == 'Survey'){
incident.state = 'In Progress';
incident.u_substate = 'Message sent';
} else {
return;
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2023 07:31 PM
Hi @SG23
You can write a After Insert/Update Business Rule on Incident Task table like the one below.
(function executeRule(current, previous /*null when async*/ ) {
var incGr = new GlideRecord('incident');
if (incGr.get(current.incident)) {
if (current.u_task_opinion == 'Make') {
incGr.state = '1';
incGr.update();
} else if (current.u_task_opinion == 'Survey') {
incGr.state = 'In Progress';
incGr.u_substate = 'Message sent';
incGr.update();
}
}
})(current, previous);
Please make sure for u_task_opinion field you are using backend values of Survey and Make.
Anvesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2023 07:17 PM
Hi, OOB state values for tasks are an integer value, so if you are setting the state in a backend script you need to use the appropriate integer IE the New value is 1 and not the values label\text.
/sys_choice_list.do?sysparm_query=name%3Dincident%5Eelement%3Dstate&sysparm_view=