Flow designer for Sc Task

rajeshraji1
Tera Expert

Can anyone suggest a workflow to handle this scenario: When a catalog item is created, it generates a Request Item (RITM) and a Service Catalog Task (SCTASK). If the SCTASK is closed, the RITM should close automatically. If the SCTASK is skipped, the RITM should also be skipped automatically."

 

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@rajeshraji1 

you can use after update business rule on SC Task table

Condition: current.request_item.cat_item.name == 'Your Item'

Script:

(function executeRule(current, previous /*null when async*/) {
    // Get the RITM associated with the SCTASK
    var ritm = new GlideRecord('sc_req_item');
    if (ritm.get(current.request_item)) {
        if (current.state == '3') { // Closed Complete
            ritm.state = '3'; // Closed Complete
            ritm.update();
        } else if (current.state == '7') { // Skipped
            ritm.state = '7'; // Skipped
            ritm.update();
        }
    }
})(current, previous);

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

View solution in original post

3 REPLIES 3

lpruit2
Kilo Sage

Greetings,

 

Would you consider a Business Rule instead of a Flow for this request? The reason I ask this is because when you go into Flow Designer the RITM table [sc_req_item] is NOT available to pick as the Trigger condition (screenshot included). 

lpruit2_0-1746402572866.png


If you still prefer the Flow Designer approach you could create a Business Rule that establishes the trigger condition and then use the Flow API to call a Subflow that handles the state change. It would be one less step if you created JUST the Business Rule and used it for the trigger condition AND to handle the actual State change. 

lpruit2
Kilo Sage

Apologies as I was starting from the RITM table and not the SCTASK table. This should be possible in Flow Designer. 

lpruit2_1-1746403434175.png


You could build your Trigger condition to be more specific if you desire to do so. Then you can use the "Update Record" Flow Action. 

lpruit2_2-1746403567168.png

Within the "Update Record" Flow Action step, click on the data-pill picker next to the Record field and dot-walk to the parent record of the Trigger record. 

lpruit2_3-1746403654829.png

I hope this answers your question and, as always, look forward for other's opinions for possible solutions. 

Ankur Bawiskar
Tera Patron
Tera Patron

@rajeshraji1 

you can use after update business rule on SC Task table

Condition: current.request_item.cat_item.name == 'Your Item'

Script:

(function executeRule(current, previous /*null when async*/) {
    // Get the RITM associated with the SCTASK
    var ritm = new GlideRecord('sc_req_item');
    if (ritm.get(current.request_item)) {
        if (current.state == '3') { // Closed Complete
            ritm.state = '3'; // Closed Complete
            ritm.update();
        } else if (current.state == '7') { // Skipped
            ritm.state = '7'; // Skipped
            ritm.update();
        }
    }
})(current, previous);

If my response helped please mark it correct and close the thread so that it benefits future readers.

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