- 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:06 PM - edited 10-04-2023 07:22 PM
Hi @SG23
You can create a UI Policy and make it to work on onLoad too with condition like,
Task Opinion :: is One of :: Make, Survey
And in the Script tab of UI Policy for True script field add this code,
var task_opinion = g_form.getValue('u_task_opinion');
If ( tasktask_opinion == 'Make'){
g_form.clearOptions('state');
g_form.addOption('state', '1', 'New');
} else if ('u_task_opinion' == 'Survey'){
g_form.clearOptions('u_sub_state');
g_form.clearOptions('state');
g_form.addOption('state', '2', 'In Progress);
g_form.addOption('u_sub_state', 'Mesage Sent', 'Message Sent');
}
And in false script,
Add all the values you want in the state fields like above.
Anvesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2023 07:15 PM
Okay sure, can this be done via script include ?
actually I want the Incident state/substate to get updated when the 'u_task_opinion' field on Incident task is set to different values (sorry this part is not added). Thanks.
- 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:34 PM
Thanks for your help!