How to exclude all order guides from Service Operation Workspace

Sandeep D V
Tera Contributor

We have a requirement to exclude all order guides from the Service Operations Workspace.

Currently, the out-of-the-box functionality displays both catalog items and order guides when we click on the 'Create Request' UI action on the Interaction form in the Service Operations Workspace. However, our requirement is to display only catalog items, excluding order guides, in the Service Operations Workspace.

How can we achieve this customization?

UI Action Script:

function onClick() {
    var result = g_form.submit('sysverb_ws_save');
    if (!result) { // failed form submission
        return;
    }
    result.then(function() {
        var params ={};
        params.sysparm_parent_table = "interaction";
        params.sysparm_parent_sys_id = g_form.getUniqueValue();
        g_service_catalog.openCatalogItem('sc_cat_item', '-1', params);
    });
}
19 REPLIES 19

@Ankur Bawiskar 
Added the log and checked, it's not going inside 'if'.

@Sandeep D V 

Can you print what came in the URL?

var url = gs.action.getGlideURI();
gs.info('URL is' + url);
if (url.toString().indexOf('/now/sow/record/') > -1)
    answer = false;
else
    answer = true;

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

@Ankur Bawiskar 
I am getting below output:

*** Script: URL issys.scripts.do?doc=%2f**%0a+%0a*+Description%3a+%240%0a+%0a*+Parameters%3a+%0a+%0a*+Returns%3a%0a*%2f%0a+&for=for+(var+i%3d0%3b+i%3c+myArray.length%3b+i%2b%2b)+%7b%0a+%2f%2fmyArray%5bi%5d%3b%0a+%0a%7d%0a%0a+&go_to_input_=&info=gs.addInfoMessage(gs.getMessage(%22%240%22))%3b&method=%2f*_________________________________________________________________%0a+++*+Description%3a%0a+++*+Parameters%3a%0a+++*+Returns%3a%0a+++________________________________________________________________*%2f%0a+++%240%3a+function()+%7b%0a+++%0a+++%7d%2c%0a&quota_managed_transaction=on&record_for_rollback=on&runscript=&script=var+url+%3d+gs.action.getGlideURI()%3b%0ags.print('URL+is'+%2b+url)%3b&sys_original.script=&sys_scope=global&vargr=var+gr+%3d+new+GlideRecord(%22%240%22)%3b%0agr.addQuery(%22name%22%2c+%22value%22)%3b%0agr.query()%3b%0aif+(gr.next())+%7b%0a+++%0a%7d%0a&vargror=var+gr+%3d+new+GlideRecord('%240')%3b%0a+%0avar+qc+%3d+gr.addQuery('field'%2c+'value1')%3b%0a+%0aqc.addOrCondition('field'%2c+'value2')%3b%0agr.query()%3b%0a+%0awhile+(gr.next())+%7b%0a%0a+%0a%7d%0a%0a+

@Sandeep D V 

what's the actual URL in log when someone visits the workspace and clicks that link?

it should have something related to workspace in it, which you can use in your script as identifier

 

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

@Ankur Bawiskar 
When we click on 'Create Request' UI action on interaction record in SOW, the URL will be:
https://domain.service-now.com/now/sow/record/interaction/3665915fdb96a01025843ede7c96191c/sub/recor...