Function returning multiple values

SG23
Tera Expert

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;

}

1 ACCEPTED SOLUTION

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);

AnveshKumarM_0-1696473005986.png

 

AnveshKumarM_1-1696473020887.png

 

Please make sure for u_task_opinion field you are using backend values of Survey and Make.

 

Thanks,
Anvesh

View solution in original post

5 REPLIES 5

Tony Chatfield1
Kilo Patron

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=