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

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @Lkowalski 

 

If there are more than 1 task on same RITM then how it work?

*************************************************************************************************************
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]

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

Hi @Dr Atul G- LNG 

Yes, one SCTASK on same RITM.

For example If SCTASK state = Pending, then RITM state should change automatically to State = Pending

For this you need to add condition or create a BR mate. 

 

 

*************************************************************************************************************
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]

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

I create a BR. You can see it in my post but it does not works.