Set Req state same as RITM state when the state changes in RITM with flow designer.

LakshmiNarayan7
Mega Guru

When the state field changes in RITM then, REQ state needs to be changed.

RITM States:                      REQ States :                        

 Open                                    Pending Approval.

 Closed Complete.                Approved, Closed Complete

 Closed Incomplete              Closed Incomplete, Closed Cancelled, Closed Rejected

 Closed Skipped                   Closed Skipped

 

For Approval the state changes works fine, But not for the rejection alone.

 

1 ACCEPTED SOLUTION

Willem
Giga Sage
Giga Sage

Is Request and Requested Item always a one-to-one? If not, I think there is a better solution.

 

If it is a one-to-one your script works with a few tweaks:

Create an After Update Business rule on the Requested Item with following code:

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

    var request = new GlideRecord('sc_request');
    request.get(current.request)
    if (current.state == '3') {
        request.active = false; // set active to false
        request.request_state = '3'; // Set state to closed Complete
        request.update();
    }
    else if (current.state == '4') {
        request.active = false; // set active to false
        request.request_state = '4'; // Set state to closed Incomplete
        request.update();
    }

}

 

View solution in original post

10 REPLIES 10

Please find the attached log message.

Willem
Giga Sage
Giga Sage

Hope you are doing well.

Is your question resolved? Or do we need to follow-up on this?

Please mark this answer as correct if it solves your question. This will help others who are looking for a similar solution. Also marking this answer as correct takes the post of the unsolved list.
Thanks.

Kind regards,

Willem

Hello Willem, Still facing the issue.

Looks like this is a prod issue as well.

Some BR is causing this. How to find that BR?

Check for business rules on the sysapproval_approver, sc_req_item and sc_request table that have been altered. Check the business rules for 'update()' in the script. And then see if any of the ones that are left after that, could be the cause.

Will I be able to avoid BR on Flow Designer while updating Request record.