How to create new Tasks on the existing RITMs

Madhura5
Tera Contributor

Hi All,

We have a requirement that ITIL users should be able to add new tasks to the existing RITMs for some specific catalog items. The RITM also has tasks which are generated through the workflow.

If we allow the ITIL users to add the tasks dynamically, the RITM closes if the tasks generated through the workflow are closed. (Manually added tasks are still open)

How can we prevent the RITM from closing until all the tasks (generated through workflow + manually added) are closed.

Thanks,

Madhura

4 REPLIES 4

Yash Agrawal1
Tera Guru

Hello MAdhura,

Please write On before Businesses rule on Ritm which will not allow anyone to close the ritm untill the task are not close.

In "When to run" tab of Business rule write condition 

state changes to closed.

Pleasse check below image

find_real_file.png

Code will be

var gr=new GlideRecord('sc_task');//catalog task table name

gr.addQuery('request_item',current.number);//filtering record

gr.query();

while(gr.next())

{

  if(gr.state!='3')//Please keep right state value of Task CLosed

  current.setAbortAction(true);

}

Please Mark it helpful/correct if my answer helps in any way to resolve your query.
Reach out to me if any more help required.

Regards

Yash.K.Agrawal

Hello Madhura,

Did your query resolve from my answer.

If Yes then please mark my answer CORRECT and HELPFUL

If no ,Please keep posted so that I can help you.

Regards,

Yash Agrawal

asifnoor
Kilo Patron

Hi,

Write a before update BR on ritm and check like this

Conditions: state changes to closed complete

Script

var gr=new GlideRecord('sc_task');
gr.addEncodedQuery("request_item="+current.sys_id+"^state!=3");
gr.query();
if(gr.next())
{
  current.setAbortAction(true);
}

Mark the comment as a correct answer and helpful if it helps to solve the problem.

Or you can check like this as well, where it checks for open and pending

gr.addEncodedQuery("request_item="+current.sys_id+"^state=1^ORstate=-5");