Passing parent URL parameters from Configurable workspace to service portal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2023 12:05 AM
Hello,
I have a requirement to replicate a native UI functionality into configurable workspace.
Once you click on the save button on the case record, it should redirect to open the service portal in a new tab and parent parameters(table name and sys_id of the parent record should be passed to the url).
I am able to achieve the redirection using a workspace client script on the 'Save' UI action.
var result = g_form.submit('sysverb_ws_save');
if (!result) {
//failed form submission
return;
}
result.then(function() {
var params = {};
params.parent_table = "my_table_name";
params.parent_sys_id = g_form.getUniqueValue();
g_service_catalog.openCatalogItem('sc_cat_item','-1', params);
});
}
As you can see, I am passing the parameters here. But, when I try to retrieve these parameters in one of the widgets using $sp.getParameter("parent_sys_id") on the server side, I get null value.
I tried to print the url using window.location.url and I get "https://instancename.service-now.com/swp"
which means the parameters are not getting passed to the url from UI action.
Can anyone please help, where I am making a mistake? or any other way to achieve this in configurable workspace?
P.S. Same script works for the Agent workspace.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2023 11:11 AM
Same question, haven't managed to find a solution just yet.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2023 11:58 AM
Any luck on finding the solution? I have the same question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-11-2023 06:55 AM
Hopefully this one will help out somebody if needed
I needed to get the parameter given from the "create request" into a client script, in my case the sysparm_parent_sys_id. Ofcourse I could just simply get the current record ID.
Hope this helps 😀
Catalog Client script on load:
function onLoad() {
//Type appropriate comment here, and begin script below
alert(getUrlParamFromWorkspace('sysparm_parent_sys_id'));
function getUrlParamFromWorkspace(paramName) {
var url = decodeURIComponent(top.location.href); //Get the URL and decode it
var workspaceParams = url.split('extra-params/')[1]; //Split off the url on Extra params
var allParams = workspaceParams.split('/'); //The params are split on slashes '/'
//Search for the parameter requested
for (var i=0; i< allParams.length; i++) {
if(allParams[i] == paramName) {
return allParams[i+1];
}
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-15-2024 06:22 AM
Perfect, thanks for this - just what I needed!
In my scenario I'm selecting a list of assets to create a transfer order for with a list action in the HAM workspace, and then forwarding the user to a catalog item which grabs those selected sys_ids from the URL.