We're reclaiming inactive PDIs to keep them available for active builders. Learn what's changing, who's affected, and how to protect your work. Read More

Prevent auto closing the RITM when any one of SC tasks are open

suryaogeti1
Tera Contributor

Hi Team,

 

We have a flow created for all the catalog items. The Sc task should auto create, and if SC task will close the RITM also auto closes, and it will update accordingly. Now the client wants another requirement like for one RITM one SC task is generating, and here the user created second SC task manually and it is linked to same RITM. If we close the auto generated SC task, the RITM is closing even though the manually created is still open. We can't the flow in the floe designer as we have 100's of catalog items, each having a separate flow. How we can overcome this. i have used BR, it is not applying for manually created SC task. When I use the BR, if I close the auto generated SC task, the RITM is auto closing, it is not caring about the manually created SC task. Please help me with this

3 REPLIES 3

Tanushree Maiti
Tera Patron

Hi @suryaogeti1 

 

Create a Before Insert/Update BR for it.

 

Try this:

  • Name: Prevent RITM Closure if SCTASK is Open
  • Table: Catalog Task (sc_task)
  • When: before
  • Insert/Update: Check both Insert and Update
  • Advanced: Check

        Conditions

  • State [is one of] Closed Complete, Closed Incomplete, Closed Skipped

 

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

    var grTask = new GlideRecord('sc_task');

    grTask.addActiveQuery();

    grTask.addQuery('request_item', current.request_item);

    grTask.addQuery('sys_id', '!=', current.sys_id); // Exclude the current task being closed

    grTask.query();

    if (grTask.hasNext()) {

        gs.addErrorMessage('You cannot close this Request Item while there are still open Catalog Tasks.');

        current.setAbortAction(true);

    }

 

})(current, previous);

 

Also you can check this: Restrict RITM Closure when SCTASK is Open using Business Rules

 

https://www.servicenow.com/community/sysadmin-forum/restrict-ritm-closure-when-ctask-is-open-busines...

 

 

Please Accept the solution if it assisted you with your question & Mark this response as Helpful.
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti

suryaogeti1
Tera Contributor

The existing flow is over riding

Ankur Bawiskar
Tera Patron

@suryaogeti1 

why you can't use before update BR on sc_task which stops the closure?

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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