Issues with close of RITM's and Catalog Tasks

Vaishnavi35
Tera Guru

Hi,

1. When Tasks are closed, RITM is not getting closed. (RITM should close once the Catalog Task is closed)
2. When RITM is cancelled/closed Tasks should cancel or close . Approvals No longer required.

Vaishnavi35_0-1687518970924.png

Code does not work. The Tasks are getting closed just fine but the RITM state automatically moves to "Closed Incomplete" though I am marking it as Closed Complete , once the form reloads it moving to closed incomplete. Not sure why.

3. Once the RITM is closed REQ is not getting closed and still "Active".

 

Please help me fix this issue!

 

Thanks,

Vaishnavi

1 ACCEPTED SOLUTION

This happening because your workflow is attached to the RITM and it is still going to proceed with the flow. There is only one functionality which cancel the workflow upon ritm cancelation. 

If you close complete the RITM and there is still few activities in the workflow to be executed. it will execute that. 

 

Make sure to close RITM upon completion of Workflow. you can do one thing before this activity. You can put a if statement and check if RITM is closed complete or not and according proceed the flow.

 

Please mark it Correct if it resolves your query.

View solution in original post

24 REPLIES 24

You do not need to run the above business rule when state changes to closed incomplete as we have an oob business rule which changes the task to closed incomplete when request or ritm goes to cancel stage 

 

"Close Tasks Due to Cancellations" is the business rule.

Hi,

Vaishnavi35_0-1686837960650.png

 

I had removed that earlier itself.

 

Here the issue is,

even when I moved the state to "Closed Complete", its updating as " Closed Incomplete".

Example ,

1. RITM - Closed Incomplete (When I try to move the RITM state to Closed Complete , it automatically moves to Closed Incomplete")

    Task 1 - "Closed Complete"

    Task 2 - "Closed Incomplete"

    Task 3 - "Closed Incomplete"

2. 

RITM - Closed Incomplete (When I try to move the RITM state to Closed Incomplete , it stays as it is and all the task states to Closed Incomplete even for the closed records")

    Task 1 - "Closed Incomplete"

    Task 2 - "Closed Incomplete"

    Task 3 - "Closed Incomplete"

 

This is the issue. I think the code needs to be corrected.

 

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

	// Add your code here
var catTask = new GlideRecord('sc_task');
catTask.addQuery('request_item', current.sys_id);
catTask.addQuery('active',true);
catTask.query();
while (catTask.next()) {
    catTask.state = '3';
    catTask.work_notes = "Closing Task as RITM is closed";
   catTask.update();
}
})(current, previous);

 

If you can please help me on that?

 

Thanks for all the help.

There could be another business rule which is making the above issue, This is because the script above is updating value as 3 for state which is closed complete and where as closed in complete has a value of 4. 

 

You can make the above business rule as active false and then you can test. that can give you a clear picture. 

Hi,

Business rules where script contains "state".

Vaishnavi35_0-1687175359796.png

Not sure where is the issue. I have tried disabling the business rule and submitting the request. 

I have moved the RITM to Closed Complete. Nothing works.

But when I moved RITM to "Closed Incomplete" , all the tasks move to Closed Incomplete irrespective of the old/active tasks.

 

I have enabled and tested again,

The RITM state is automatically moving to "Closed Incomplete" but the all tasks are moving to closed complete.

Should we write any condition???

Like current.stage!='Request Cancelled' etc.,

// Add your code here
var catTask = new GlideRecord('sc_task');
catTask.addQuery('request_item', current.sys_id);
catTask.addQuery('active',true);
catTask.query();
while (catTask.next()) {
    catTask.state = 3;
    catTask.work_notes = "Closing Task as RITM is closed";
   catTask.update();
}

 

Help?

 

Thanks,

Vaishnavi

Depending on your use cases you can add multiple if statements and populated/update the value of states accordingly.