271 views

Description

Currently, the out of box business rule Reduce request price - approval change does not validate if sc_req_item.request has a valid sys_id. Because of this, when it runs, if there are many requested items with an empty request, then all of them will be checked. This can cause slow performance on the affected node.

Steps to Reproduce

  1. Create many (50k) sc_req_item records with an empty sc_request value
  2. Create an approval on a sc_req_item
  3. Change the sourceTable of the approval to sc_req_item, to trigger the business rule
  4. Observe slow performance as the business rule scans all the orphaned sc_req_item records

Workaround

Update the following script to validate if sc_req_item.request has a valid sys_id:

Reduce request price - approval change ../sys_script.do?sys_id=b8cfcdd2c3300200e3fddfdc64d3ae3c

Updated:

function onAfter(current, previous) {

var gr = new GlideRecord("sc_req_item");

gr.addQuery("sys_id", current.sysapproval.sys_id + "");

gr.query();

if (gr.next() && gr.request.sys_id) {

var request = new SNC.Request(gr.request.sys_id + "");

if (request)

request.recalculateAllPrices();

}

}

 Original:

function onAfter(current, previous) {

var gr = new GlideRecord("sc_req_item");

gr.addQuery("sys_id", current.sysapproval.sys_id + "");

gr.query();

if (gr.next()) {

var request = new SNC.Request(gr.request.sys_id + "");

if (request)

request.recalculateAllPrices();

}

}

 
 
 

Related Problem: PRB731372

Seen In

There is no data to report.

Fixed In

Istanbul Patch 6
Jakarta

Associated Community Threads

There is no data to report.

Article Information

Last Updated:2018-04-17 09:09:06
Published:2017-05-22