Navigate to Catalog item and Populate item variables when clicking on UI Action
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2022 04:25 AM
Hi All,
We have a requirement to navigate to a catalog item from a UI Action which is present on a form in custom table.
While the user clicks on the UI Button, then the group id from the form has to be populated on the catalog form and based on the group id , remaining fields have to be autopopulated based on group id .
I have written the following script but I am unable to navigate to the url
UI action script :
Client callablle- yes
Onclick - redirectCat()
function redirectCat(){
var myGroupid = current.sys_id;
var ct = "https://company.service-now.com/itsp?id=itsp_sc_cat_item&sys_id=c6ea768c877d4150b81f0d030cbb3534&sysparam_group_id="+ myGroupid ;
g_navigation.openPopup(ct);
Catalog client script onLoad :
function onLoad()
var url = top.location.href;
url = url.split('group_id=');
var myGroupid = url[1];
//alert(myGroupId);
if (myGroupid) {
g_form.setValue('group_id', myGroupId);
}
Could someone please help me where the issue is in the script.
Thank you
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2022 04:30 AM
Try below:
var url = new URL(this.location.href);
var grp= url.searchParams.get("sysparam_group_id");
g_form.setValue('group_id',grp);
Raghav
MVP 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2022 04:44 AM
Hi @Raghav the above solution is still not working.
Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2022 04:55 AM
1. Please check isolate script is true in your client script
2. alert (this.location.href); and check if you are getting correct URL in your client script.
3.Try changing sysparam_group_id to sysparm_group_id in your UI action and client script.
Raghav
MVP 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2022 12:04 AM
Hi @Raghav it is still not working