Leveraging Workplace Service Items in a Workplace Case Record Producer

keithlyon22
Mega Guru

I have a requirement to display a list of Workplace Service Items based on a location selected by an indoor map on a WSD Case Record Producer. Is there any baseline functionality that would help with this? The Macro that generates the location data does not seem to store any data on the form so it is not available to use for a standard glide ajax call. We could potentially get the data using DOM manipulation, but trying to avoid that. 

1 REPLY 1

Riya Verma
Kilo Sage
Kilo Sage

Hi @keithlyon22 ,

 

Hope you are doing great.

 

To implement this solution, follow these steps:

  1. Open the WSD Case Record Producer form in the ServiceNow Designer.
  2. Locate the field representing the indoor map location selection.
  3. Identify the reference field that holds the Workplace Service Items on the form.
  4. Edit the reference field and navigate to the "Advanced" tab.
  5. Look for the "Reference Qualifier" field and click on the edit button.
  6. Write the necessary code within the "Reference Qualifier" field to filter the Workplace Service Items based on the selected location.

Below is script you can reference:

location=javascript:current.location;

// Create a GlideRecord object for the Workplace Service Items table
var gr = new GlideRecord('workplace_items');
gr.addQuery('location', location);
gr.query();

// Build the query string to filter the Workplace Service Items based on the selected location
var query = 'sys_idIN';
while (gr.next()) {
  query += gr.sys_id + ',';
}
query = query.slice(0, -1); // Remove the trailing comma

// Return the constructed query to filter the Workplace Service Items
return query;
Please mark the appropriate response as correct answer and helpful, This may help other community users to follow correct solution.
Regards,
Riya Verma