Close Tab in workspace once the record producer is submitted

arey yaar
Giga Guru

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. 

areyyaar_1-1690887726605.png

 

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

 

areyyaar_0-1690887391882.png

 

1 REPLY 1

Rick Spies
Tera Contributor

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.