Notifications

21 views

Symptoms


Catalog Client Script which uses the output of a GlideRecord query to set a reference field does not work in the Service Portal. It only works on the Platform side.  The source code looks like so:

 

var query_result = new GlideRecord('sys_user'); 

query_result.addQuery('sys_id', some_user); // will lookup the sys_id of another sys_user using some_user as a reference

query_result.query(); // execute query

if (query_result.next()) { // fetch the next result set of the query

     g_form.setValue('reference_field_name',  query_result.manager); // setting the field to the manager of some_user

}

Release


All

 

Cause


The appropriate API for this functionality is a little different for Service Portal. Specifically, a callback parameter is required for the catalog client script to work both on the Service Portal and Platform. 

Resolution


Modify the Catalog Client Script like so:

 

var query_result = new GlideRecord('sys_user');

query_result.addQuery('sys_user', some_user);

query_result.query(callBackFunction);

function callBackFunction(query_result) {

     if (query_result.next()) {

        g_form.setValue('reference_field_name', query_result.manager):

      }

}

Additional Information


Additional documentation around this area can be found here:

Article Information

Last Updated:2019-03-03 20:06:07
Published:2019-03-04