367 views

Description

A business rule named 'request closure' runs on the sc_request table when a request has been closed as Cancelled or Incomplete. The business rule incorrectly performs a check against child sc_req_item records ("children.stage != 'Complete'") in the script. This statement always evaluates to true, as Complete is not a valid stage on an item. As a result, requested items that may have already reached a Complete (finished) state have their stages changed.

Steps to Reproduce

  1. Open the Service Catalog.
  2. Do one of the following:
    • Use an Order Guide to order multiple items.
    • Manually add a few items to your cart.
  3. Check out the items.
  4. Go through the process for one of the items so the items reaches the Complete stage. Other items that are open or not yet completed should still be available.
  5. Open the parent Request record.
  6. Change the Request state to Closed incomplete or Closed cancelled (this triggers the "request closure" business rule). For items that are not completed, the stage is set to Request cancelled and Active is set to false. However, the item that has been completed is also changed to Request cancelled.

Workaround

This workaround only works for Fuji Instances. For Geneva Instances, there is no workaround possible, because the fix is in Java Layer.

  1. Navigate to System Definition > Business Rules.
  2. Search for and open the business rule named "request closure." 
  3. Replace the following code:

    function cancelKids() {
            var children = new GlideRecord('sc_req_item');
            children.addQuery('request', current.sys_id);
            children.query();
            while (children.next())
            if (children.stage != 'Complete') {
                     children.stage = 'Request Cancelled';
                     children.active = false;
                     children.update();

            }




    with this code:

    function cancelKids() {
             var children = new GlideRecord('sc_req_item');
             children.addQuery('request', current.sys_id);
             children.query();

             while (children.next()) {
                  if (children.state != 3 ) {
                        children.stage = 'Request Cancelled';
                        children.active = false;
                        children.update()

                 } 

            }

    }


Related Problem: PRB635062

Seen In

Fuji Patch 3

Fixed In

Fuji Patch 11
Geneva Patch 1
Helsinki
Istanbul

Associated Community Threads

There is no data to report.

Article Information

Last Updated:2016-06-03 15:26:27
Published:2015-10-15