Notifications

391 views

Description

Business rule to populate default values has performance issue with large data set.

Steps to Reproduce

 

Create a reference interactive filter on a large table, for example, Users. (For more information, see the product documentation topic Create a reference field interactive filter.)

Note that the default values take a long time to load the data.

Workaround

The workaround for this issue has two stages. The first is to edit business rules and script includes to limit the number of records in a query to a specified value to reduce out of memory errors. In this example procedure, the limit is 10,000. The second stage is to add conditions to reference filters to limit a specific set of records to fetch.

Edit the business rules and script includes:

  1. Navigate to System Definition > Business Rules.

  2. Open the GetDynamicaTableValuesForFilter business rule.

  3. On the Advanced tab, update the getDynamicValueForSelectedTable function with the line grp.setLimit(10000);.

    function getDynamicValueForSelectedTable
    var gp = [];
     
    var grp = new GlideRecord(current.reference_table); 
    if(current.reference_conditions)
       grp.addEncodedQuery(current.reference_conditions);
    grp.setLimit(10000);
    grp.query();
    while(grp.next()) {
       answer.add(grp.getDisplayValue("sys_id"),grp.getDisplayValue(grp.getDisplayName()))
    }
    answer;
    }
     
  4. Click Save.

  5. Navigate to System Definition > Script Includes.

  6. Open the ReferenceFilterTableSelection script includes.

  7. Update the script with the line grp.setLimit(10000);.

    var ReferenceFilterTableSelection = Class.create();
    
    ReferenceFilterTableSelection.prototype = Object.extendsObject(AbstractAjaxProcessor, {
    
       getRecords: function(){
          var gp = [];
          var table = this.getParameter(sysparm_reference_table);
          var conditions = this.getParameter("sysparm_reference_conditions");)
       
       var grp = new GlideRecord(table);
       grp.addActiveQuery
       if(conditions)
          grp.addEncodedQuery(conditions);
       grp.setLimit(10000);
       grp.query();
       while(grp.next()) {
          gp.push(this.getRecordJSON(grp))
       }
       var result = this.newItem("result");
       result.setAttribute("record",JSON.stringify(gp));
       return JSON.stringify(gp);
    },
    getRecordJSON: function(gr){
       var record = {};
       record.key = gr.getDisplayValue("sys_id");
       record.value = gr.getDisplayValue(gr.getDisplayName())
       
       return record;
    },
    type: 'ReferenceFilterTableSelection'
    });
  8. Click Save.

    Result: Result sets are limited to 10000 entries, preventing out of memory errors and speeding up the return of information.

Add conditions to reference filters to limit a specific set of records to fetch:

  1. Navigate to Reports > Interactive Filters or Homepage Admin.

  2. Select the reference interactive filter to edit.

  3. Add an appropriate filter condition.

    Appropriate conditions depend on the information you are working with. 

  4. Click Update.

    Result: The data set being queried for the interactive filter is limited by the filter condition.

 


Related Problem: PRB995883

Seen In

There is no data to report.

Fixed In

Istanbul Patch 7
Jakarta Patch 1
Kingston

Associated Community Threads

There is no data to report.

Article Information

Last Updated:2018-01-29 09:52:52
Published:2017-11-15