'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
2 weeks ago
Thanks @Kelly Logan, the screenshot and scripts help a lot. I think there are three separate things going on, and one of them may explain why the hide/show combination isn't behaving.
1. The sys_id isn't exactly "-1"
You noted earlier that the URL ends in -1_uid_5 or -1_uid_7, with a suffix that changes between runs. That suffix is added so each new-record route is unique, which means props.sysId arrives as "-1_uid_5", not "-1". A condition of sysId = -1 will never match, so both components end up in the wrong state. Check for the prefix instead, for example in the hide script for Catalog browse:
return !String(api.context.props.sysId || '').startsWith('-1');and the opposite for the Catalog item component.
2. Use a client script for the navigation instead of "Open page or URL"
The greyed-out pills in the binding dialog usually mean the field you're binding expects a different data type from the value you're offering, so the dialog won't let you pick them. Rather than fighting the declarative handler, map CATALOG_BROWSE#CATALOG_ITEM_SELECTED to a page client script and navigate with the documented helpers.navigate.to method, which takes the route, fields and params directly:
function handler({api, event, helpers, imports}) {
// Log once while testing to confirm the payload path
console.log('Catalog item selected', event.payload);
const item = event.payload.catalog_item_details || {};
const params = {};
if (api.context.props.extraParams) {
params['extra-params'] = api.context.props.extraParams;
}
helpers.navigate.to(
'record',
{ table: item.sys_class_name || 'sc_cat_item', sysId: item.sys_id },
params,
false, // redirect
false, // passiveNavigation
'current' // targetRoute: stay within the current tab
);
}Notes on the script:
- The payload path comes from your screenshot (catalog_item_details holds sys_id and sys_class_name). The console.log will confirm it on your release.
- Field names are camel case: sysId, not sys_id. Using sys_id in the fields object gives you "undefined" in the URL.
- The targetRoute of 'current' keeps the navigation inside the workspace tab rather than opening a new browser tab, which is the behaviour you were seeing with "Open page or URL". Because you're already on a sub-route of the interaction, check the resulting URL; if it nests in a way you don't want, try setting redirect to true instead.
3. Pass the extra params through unchanged
Your three IFrame scripts all parse the same extraParams string (parent_table, parent_sys_id and so on) from page props. So rather than rebuilding each value, the script above passes the original extraParams string straight through to the new route. The parameter key 'extra-params' matches what appears in your original URL, so after clicking an item, compare the new URL with the one the UI Action produced. If the extra-params segment looks the same, the Catalog item component (and your existing parsing scripts) will see the same parent table and sys_id.
One last check: if you use record producers or order guides from interactions, sys_class_name will be sc_cat_item_producer or sc_cat_item_guide, so add those tables to your variant's condition, or hard-code 'sc_cat_item' as the table so every click lands on the same variant.
Let us know how you get on, especially whether the request links back to the interaction after submitting.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 weeks ago - last edited 2 weeks ago
HI @Kelly Logan ,
Make a Service Operations Workspace (SOW) record page that displays catalog items the way the out-of-box SOW catalog item page does.
Steps
- Open UI Builder and select your custom workspace.
- Open the Record page.
3. Click More actions on the record page and select Create new variant. Then choose Create from scratch instead.
4. Enter a Variant name. In Conditions, add: table is Catalog Item OR table is Record Producer OR table is Order Guide. Click Continue.
5. An empty page opens.
6. Go to the Settings tab and open the Open records dropdown.
7. Select Open page definition.
8. In a new tab, open the SOW catalog item page definition:
https://<your-instance>/now/nav/ui/classic/params/target/sys_ux_macroponent.do%3Fsys_id%3D7c49ae3453613010bf68ddeeff7b1292
9. Copy these fields from the SOW page definition into your own page definition, then click Save:
- Layout Model
- State
- Properties
- Keyboard Shortcuts
- Internal Event Mappings
- Composition
10. In the SOW page definition, scroll to the UX Client Scripts related list. Open each script one by one. In your own page definition, click New under UX Client Scripts and recreate it, copying the Name and Script fields.
Return to your UI Builder variant and check that it matches the SOW catalog item page.
If my response helped mark as helpful and accept the solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 weeks ago
(Note: This is a workaround that copies the Catalog IFrame instead of making the 'best practice' Catalog Browse and Catalog Item components work. As such, I consider NagaChandaE's info as helpful but not the real solution.)
Following these directions, when I returned to UI Builder and switched from the Settings to the Editor view, I was given a notice that new page info was being incorporated, and the display (which had test values for a specific cat item) displayed the catalog item (which it wasn't doing before). I also got three new warnings, one for each of the scripts (see screenshot).
A couple notes:
- The UX Macroponent Definition entry for SOW has a category of "macroponent", which is not available from the Category menu on the new entry. Left it as Category = "Page".
- The "Internal Event mappings" - Assumed to mean 'Dispatched Events' and 'Handled Events'. Note that Dispatched Events were set to "Open page or URL Relay (Catalog Item) on the new page, but not on the SOW version. Removed it for now.
- The UX scripts also had slightly different formats for the entries.
Here's the SOW version:And the new record (see below). Note that I left the Macroponent, Type and Target as set. Blank values, like in the SOW, were not an option.
On returning to the UI Builder and examining the objects there, I found that instead of a Catalog browse component, it was now a Catalog IFrame. So apparently you can recreate the object, even if you can't utilize the component directly. Sneaky, but functional. My preference would still be to learn how to use the new components the Catalog Browse and Catalog Item, to show a catalog and item the way the docs present as the new methodology, but this is a functional workaround in the meantime.