'Create Request' UI Action acting differently in custom Workspace - Displaying Create New Cat Item
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
We are working in ITSM, with the Service Operations Workspace (SOW) installed and functioning. We have created a separate custom workspace Service Desk Workspace (SDW) that is similar.
Both display Interactions, both have a similar action bar with: Save, Create Incident, Associate Record and Create Request. The first three work normally, but in the SOW, the 'Create Request' button opens the service catalog (see screenshot).
While in the SDW, the same UI Action opens a 'Create New Catalog Item' view (see screenshot).
Both Workspaces use the same UI Action, so both are calling the same 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);
});
}This is a standard script that has been discussed elsewhere in the community and docs.
(I did note that the 'Create Request' UI Action was in the 'Record Page for Service Operations Workspace' and tried to creating a new UI Action in the Global space where the SDW lives, but there was no change in results.)
The URLs for both are essentially identical other than the workspace used, so the parameters being handed in are the same:
SOW: /now/sow/record/interaction/0b1ead68935813504078f1f52603d6d1/sub/record/sc_cat_item/-1_uid_5/params/extra-params/parent_table%2Finteraction%2Fparent_sys_id%2F0b1ead68935813504078f1f52603d6d1%2Fsysparm_parent_table%2Finteraction%2Fsysparm_parent_sys_id%2F0b1ead68935813504078f1f52603d6d1
SDW: /now/service-desk-workspace/record/interaction/0b1ead68935813504078f1f52603d6d1/sub/record/sc_cat_item/-1_uid_7/params/extra-params/parent_table%2Finteraction%2Fparent_sys_id%2F0b1ead68935813504078f1f52603d6d1%2Fsysparm_parent_table%2Finteraction%2Fsysparm_parent_sys_id%2F0b1ead68935813504078f1f52603d6d1
(Note: the suffix number in the parameter -1_uid_x seems to be random. It changes between runs and if I change the URL to reflect, I get the same response on both workspaces.)
There is one clear difference I have found: The SOW has an Action Assignment entry that appears to be a link between the SOW and the UI action. The SDW does not, so I'm thinking there might have been some process and/or underlying data that exists for the SOW that created the Action Assignment entry (and maybe other pieces I haven't found yet), that was not used for the SDW.
Any ideas where else to look?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @Kelly Logan
Nice troubleshooting, and you were very close. The behaviour difference isn't in the UI Action, the script, or the URL. It's in how each workspace's record page resolves the route.
What's actually happening
g_service_catalog.openCatalogItem('sc_cat_item', '-1', params) doesn't open "the catalog" directly. It routes to the workspace's record page for table sc_cat_item with sys_id -1, which is exactly what both of your URLs show.
The difference is what each experience does with that route:
- SOW ships a variant of its record page whose condition is "table is sc_cat_item" (it also covers sc_cat_item_producer and sc_cat_item_guide). When the route matches, that variant renders the catalog browsing/ordering experience instead of a record form.
- Your custom workspace has no such variant, so UI Builder falls back to the default record page for sc_cat_item. A default record page with sys_id -1 is a new-record form, which is the "Create New Catalog Item" screen you're seeing.
Your Action Assignment finding is real but it's a side trail: action assignments control where the button appears, not how the target route renders. Your button already appears in both workspaces, so that part is fine.
The fix
- Open UI Builder for the Service Operations Workspace experience, go to its Record page, and look at its variants. You'll find the catalog one with the table condition described above (reported as "Catalog Item Page SNC" in recent releases; confirm the name in your instance).
- Open UI Builder for your Service Desk Workspace experience and create an equivalent variant of your record page, with the condition that the table is sc_cat_item (add sc_cat_item_producer and sc_cat_item_guide if you use record producers or order guides from Interactions too).
- For the variant's content, mirror what the SOW variant uses. One caveat: if the component the SOW variant uses is scoped to SOW and isn't available to add in your experience, the well-trodden fallback is a variant whose body is an iframe pointing at the catalog (service portal) with the parameters passed through. There's a good walkthrough of exactly this pattern here: https://www.servicenow.com/community/developer-forum/how-to-open-a-catalog-item-in-now-experience-wo...
- Test both paths: sys_id -1 (browse the catalog) and a real catalog item sys_id (open one item directly), since the same variant serves both.
So in short: nothing you built is wrong, and no hidden process created extra data for SOW beyond its page variant. Add the matching variant to your workspace and the same UI Action will behave identically in both.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 weeks ago
I didn't see a template appropriate for displaying cat items, so I built the variant from scratch.
No audience set. Table set to "Catalog Item" [sc_cat_item].
As you had warned, the "Catalog IFrame" used by the SOW is proprietary and can only be used in it and related spaces.
After review, noted an article saying that the "Catalog browse 1" is a more recent component that can be used and does not require an IFrame. This might be an even better option as it includes not only the catalog display but the navigation as well.
Now I just need to figure out how to set up events and handlers to pass off the so that when a user clicks on a catalog item, it opens and passes in the original extra-params.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 weeks ago
Great progress, @Kelly Logan, and good find on Catalog browse. Agreed, it's the better option: no iframe, and it's built for exactly this (it arrived in Zurich as a UI Builder component for adding catalog browsing to custom pages).
For the click-through, I have a few suggestions:
1. Let the same variant handle both routes
Your variant matches table sc_cat_item for every sys_id, so it will receive both the "browse" route (sys_id -1) and the "open this item" route (a real catalog item sys_id). Rather than building a second page, put two components on the variant and toggle them with visibility bindings on the sys_id:
- sys_id is -1: show Catalog browse.
- sys_id is a real item: show the Catalog Item component, which renders and submits both standard catalog items and record producers.
Then the click handler only has to navigate to the same route with the item's sys_id, and everything stays inside one tab.
2. Wire the click event
Select Catalog browse, open the Events tab and choose Add event mapping. The component's own dispatched events are listed there, including the one for an item being selected. Map it to a navigation handler (Link to destination or the record-opening handler in your experience; check the exact names in your handler list), with table sc_cat_item and the sys_id taken from the event payload.
3. Pass the extra params through
Your original URL already carries the parent table and sys_id in the extra params, so the variant receives them when it loads. In the navigation handler, add the same parameters to the target route, bound from the current page's properties rather than hard-coded. That way the interaction context survives the click and lands on the catalog item, just as it does in SOW.
Even though you can't reuse SOW's proprietary iframe component, I think you can still open the SOW catalog variant in UI Builder and read its event mappings and page properties. It shows how ServiceNow wires the click, the route and the parameter pass-through, and you can mirror the same structure with Catalog browse.
And ofcourse, test that the request actually links back to the interaction after submission, not just that the item opens. I think that's the part users will notice if the parameters get dropped somewhere along the way.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 weeks ago - last edited 2 weeks ago
I'm not getting the combinations quite right yet.
- I did add a Hide component script: (props > sysid = -1) with the opposite for the Catalog item 1 component.
- I added event CATALOG_BROWSE#CATALOG_ITEM_SELECTED and added a handler of type 'Open page or URL', but this is where the data seems to not be set as desired.
The event payload seems to be saying it has no valid values:
Other combinations of direct and/or scripted values seems to produce no values in the final URL/display. Also it opens in separate tab, despite being set to open on the same page.
In the IFrame the table and sysid are set from props:
Sys ID = props > sysId(null)
Catalog Item Type = props > table (null)
But three other values are set with scripts, I don't know if this is because of the noted difficulty passing values into and out an IFrame, but here are the three other values set:
Script to define the Parent Table
/**
* @Param {params} params
* @Param {api} params.api
* @Param {any} params.imports
*/
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 api.context.props.parentTable || extraParams.parent_table || extraParams.sysparm_parent_table;
}
Parent Record Id:
/**
* @Param {params} params
* @Param {api} params.api
* @Param {any} params.imports
*/
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 api.context.props.parentSysId || extraParams.parent_sys_id || extraParams.sysparm_parent_sys_id;
}
Category Id:
/**
* @Param {params} params
* @Param {api} params.api
* @Param {any} params.imports
*/
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 api.context.props.categoryId || extraParams.sysId || extraParams.category_id;
}
I noticed that the IFrame used three scripts