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

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();
    }

}

 

Willem
Giga Sage
Giga Sage

Condition of the Business rule should look like this:

find_real_file.png

Abdul Azeez
Mega Guru

Hi Laskshmi,

 

I think this is not a write approach to make the changes, because every Request may have multiple RITM's its very difficult to manage.

 

I would suggest instead of BR, you may have the workflow on RITM right, in the workflow itself you can simple use the Set Values activity  just closed successful or close incomplete.

 

Or

 

Another simple way is to try with Flow Designer

Trying in Flow, Need help with Rejection.

Approval works fine.