Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Configure catalog page in Service Operation Workspace

Paul Snowlab
Tera Contributor

Hello guys,

 

I need you help with Workspace configuration and interaction. When an agent works on an interaction, he has the possibility to create a request. If user clicks on "Create a request", agent is redirected to Service Catalog page (see attachment). I would like to configure this page to only show specific catalog(s). Anyone know if it's possible and how to configure it ?

 

Thanks for your help.

5 REPLIES 5

David Holmes
Tera Contributor

Hi @Paul Snowlab 

Did you manage to figure this out? We're having a similar issue.

Thanks
David

Paul Snowlab
Tera Contributor

Hello David,

 

Lucky for you I did. Here is the solution : 

 

1 - In the UI Builder, select the page "Record" (1st screenshot). In the list of variants, you should see one named "Catalog Item Page SNC"

2 - Duplicate the variant and select it

3 - In the body of the page, you have one widget name "Catalog iFrame". In the "Config" section, you have a field named "Catalog ID".

4 - Edit the scripted property value, add the following code. This is to read the id of the category you want to select.

function evaluateProperty({
    api
}) {
    let extraParams = {};
    
    if (api.context.props.extraParams) {
        let paramObjects = api.context.props.extraParams.split("/");
        
        for (let i = 0; i < paramObjects.length; i = i + 2) {
            extraParams[paramObjects[i]] = paramObjects[i + 1];
        }
    }

    return extraParams.catalogId;
}
 
Then you need to edit your UI action and add the catalog as a parameter.
 
So it looks like ServiceNow planned to have this possibility but it was not setup by default (which is strange). Hope this helps ! 
 

Thanks Paul!

I'll take a look.

Riya Verma
Kilo Sage

Hi @Paul Snowlab ,

 

Hope you are doing great.

 

  1. Identify the Workspace:

    • Determine the specific Workspace where the "Create a request" functionality needs to be configured.
    • Workspaces are created and customized using Service Portal, so you'll need to locate the relevant Workspace within the Service Portal configurations.
  2. Edit the Workspace Page:

    • Access the Service Portal Designer and navigate to the page associated with the Workspace where the "Create a request" functionality is present.
    • Look for the section or widget that contains the "Create a request" button or link.
  3. Modify the Catalog Display:

    • Once you have identified the section or widget, you can customize its behavior to display specific catalogs.
    • Edit the properties of the section or widget to define the filtering criteria for the catalogs that should be displayed.
  4. Apply Catalog Filtering Logic:

    •  add custom code to the section or widget to filter and display specific catalogs

below is reference code for  filtering catalog based on requirement:

var catalog = new GlideRecord('sc_catalog');
catalog.addQuery('name', 'IN', ['Catalog 1', 'Catalog 2', 'Catalog 3']);
catalog.query();

while (catalog.next()) {

  gs.print('Catalog Name: ' + catalog.name);
  gs.print('Catalog Description: ' + catalog.description);
  // Add additional logic as per your requirements
}

 

Please mark the appropriate response as correct answer and helpful, This may help other community users to follow correct solution.
Regards,
Riya Verma