Close Tab in workspace once the record producer is submitted
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2023 04:02 AM
Need to close the tab on workspace once the record producer is submitted.
Have a button on workspace called Open record producer, once i click on it, it opens the record producer.
I want to close the record producer once it is submitted.
I tried with g_aw.closeRecord(); in onsubmit catalog client script , but its giving me javascript console error - g_aw is not defined
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2024 08:22 AM
Hi Arey,
We faced a similar issue, and I seem to have found a solution.
In our case we have a UI action that opens one of our Record Producers in a new tab within the Workspace:
g_service_catalog.openCatalogItem('sc_cat_item', 'your_record_producer_sys_id', '-1', params)
This will open up the Record Producer in the Service Portal Catalog Item view inside a new tab within the Workspace.
Then to automatically close the tab after the Record Producer has been submitted you can add the following Catalog Client Script to your Record Producer:
Type: onSubmit
Applied on a Catalog Item view: true
function onSubmit() {
setTimeout(function() {
self.postMessage({
msg:'CATALOG_ITEM_CLOSED'
}, location.origin);
}, 3000);
}
I included the time out so that the user has a few seconds to visually confirm the form has been submitted. You could exclude the time out, it will then immediately close the tab after submit.
Hope this helps you out.