How to achieve if SCTASK state = Pending, then RITM state = Pending

Lkowalski
Tera Contributor

Hello All,

 

I am trying to create a Business rule which will achieve below:

if SCTASK state = Pending, then RITM state = Pending
if SCTASK state = Work in progress, then RITM state = Work in progress
if SCTASK state = Awaiting User Info, then RITM state = Awaiting Customer

 

I had created a below BR:

 SCRIPT:

I am trying to below script create a code for condition: if SCTASK state = Pending, then RITM state = Pending

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

    var ritm = new GlideRecord('sc_req_item');
    if (ritm.get(current.request_item)) {
        if (ritm.state != '1') {
            ritm.setValue('state', 1);
            ritm.update();
        }
    }
})(current, previous);

Lkowalski_0-1706799688282.png

Thank you for every answer :).

 

Regards,

Lukas

7 REPLIES 7

@Jaspal Singh 

 

any thoughts.

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

Try 

in single quote

setValue('state', 'closed_value');

 

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

@Dr Atul G- LNG any thougts how to change my script to make it work ?