how to auto populate choice field value on when change state is moved from one to another state

Payal2
Kilo Contributor

Need to set value of choice list field which is present on change task when change request is change .

when change move from one state to another .set choice field value in change task .

Example:

if change task has choice field "abc" with value as 1,2,3. also change state is in authorized state  and task choice field abc  value is 2.when change is moved from authorized to schedule state "abc" value should switch from 2 to 1.

How to implement this scenario.

1 ACCEPTED SOLUTION

Hi,

BR should be on change_request table

Condition:

State [Changes From] Authorized

AND

State [Changes To] Scheduled

Script:

(function executeRule(current, previous /*null when async*/) {

    // Add your code here

var chgTask = new GlideRecord('change_task');
chgTask.addQuery('change_request', current.sys_id);
chgTask.query();
while(chgTask.next()){
chgTask.u_confirmation = 'released';
chgTask.update();
}

})(current, previous);

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

5 REPLIES 5

Hi,

BR should be on change_request table

Condition:

State [Changes From] Authorized

AND

State [Changes To] Scheduled

Script:

(function executeRule(current, previous /*null when async*/) {

    // Add your code here

var chgTask = new GlideRecord('change_task');
chgTask.addQuery('change_request', current.sys_id);
chgTask.query();
while(chgTask.next()){
chgTask.u_confirmation = 'released';
chgTask.update();
}

})(current, previous);

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader