How to convert sys id in an URL to system property or by other means
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-28-2022 05:47 PM
I am trying to open URL a new tab when someone clicks an UI action. I got it to work with code below but when I do a healthscan I get an error not to use hard coded sys IDs. Ive turned the sys IDs within the URL to system properties and call them in the URL but am not having any luck. Any idea what wrong or any other suggestions on how to accomplish the goal.
Code that works but get healthscan error:
function openURL() {
window.open('https://itsmnow.service-now.com/$pa_dashboard.do?sysparm_dashboard=9a8184ed1b80b490f6f31f49b04bcba1&sysparm_tab=20e348e91bc0b490f6f31f49b04bcbb2&sysparm_cancelable=true&sysparm_editable=false&sysparm_active_panel=false');
}
Other things ive tried that dont work:
1.
function openURL() {
var dash = gs.getProperty('change.calendar');
var caltab = gs.getProperty('change.calendar.tab');
window.open('https://itsmnow.service-now.com/$pa_dashboard.do?sysparm_dashboard=dash&sysparm_tab=caltab&sysparm_cancelable=true&sysparm_editable=false&sysparm_active_panel=false');
}
2.
function openURL() {
var dash = gs.getProperty('change.calendar');
var caltab = gs.getProperty('change.calendar.tab');
window.open('https://itsmnow.service-now.com/$pa_dashboard.do?sysparm_dashboard=' + dash + '&sysparm_tab=' + caltab + '&sysparm_cancelable=true&sysparm_editable=false&sysparm_active_panel=false');
}
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-28-2022 09:35 PM
function openURL() {
var dash = gs.getProperty('change.calendar');
var caltab = gs.getProperty('change.calendar.tab');
g_navigation.openPopup('https://itsmnow.service-now.com/$pa_dashboard.do?sysparm_dashboard='+dash+'&sysparm_tab='+caltab+'&sysparm_cancelable=true&sysparm_editable=false&sysparm_active_panel=false');
}
Can you try this in your UI action.
Also use alert/gs.log() to check if the property value is fetching or not for dash and catlab on click of UI action.
If it works please mark the answer as correct
Anshu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-01-2022 07:48 AM
Thanks for the reply. The code you mention also didnt work. However using the alert/gs.log() to check if the property value is fetching or not resulting in it not fetching. Solution ended up creating a Display BR then capturing the Sys properties in scartchpad then calling the scratchpad in the UI action script. This solved the issue. Thanks for the help
function openURL()
{
/*****************************
getting the dashboard and tab sys_id from getproperties through business rule
Business rule used in - [USB] - Use Scratchpad to Call in UI on Display
**********************/
var dash = g_scratchpad.dash;
var caltab = g_scratchpad.caltab;
var url = "https://itsmnow.service-now.com/$pa_dashboard.do?sysparm_dashboard=" + dash + "&sysparm_tab=" + caltab + "&sysparm_cancelable=true&sysparm_editable=false&sysparm_active_panel=false";
window.open(url);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-01-2022 08:00 AM
FYI you cannot use gs object in client side; so the script you shared won't work
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-01-2022 08:12 AM
Thanks for pointing it out but for me it works. as a demo, incident form open in new tab when click on ui action button on the incident form. can you please guide me since g_navigation.openPopup and top.window.open both works , what is best practice to use.
Anshu