- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2022 03:56 PM
Hi,
I created a UI action and it's calling the instance name in the url. Since name of the instance is hardcoded. It is working as expected.
We need generic UI action so that no need to update the instance name when UI action is moved to different instance
var url = 'https://"instancename".service-now.com/"tableName"_list.do?sysparm_query=id%3D' + current.user_id.toString() ;
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2022 05:23 AM
Hi,
You just need to update your URL as below:
var url = '/tableName_list.do?sysparm_query=id%3D' + current.user_id.toString();
This will automatically take the instance name dynamically, let me know if you have a query here.
I just tested it in my PDI and it works fine. Make sure to include the below line as well:
var url = '/tableName_list.do?sysparm_query=id%3D' + current.user_id.toString();
action.setRedirectURL(url);
Hope this helps. Please mark the answer as correct/helpful based on impact.
Regards,
Shloke
Regards,
Shloke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2022 04:11 PM
There is a property in every instance with the name:make a variable that grabs this- gs.getProperty('instance_name');
More details here
https://servicenowguru.com/scripting/business-rules-scripting/finding-instance-name-via-script/
This also works in many areas like when creating URL in notifications and will save you time when you clone down and links dont work in test- using this method to build urls is the best
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2022 04:21 PM
Thank for reaching out.
I was aware of that property however I wasn't able to bring it on UI action
FYI - that property is missing from our instance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2022 05:44 PM
If you are referring to 'gs.getProperty('glide.servlet.uri');'
Then it is available in your instance for server side scripts, even if not visible as a system property.
You can access this property client side via an ajax call, an example from Harshvardhan
https://community.servicenow.com/community?id=community_question&sys_id=ae72fed5dbfb88d41cd8a345ca9619d1
Or this may be another option, from Jace Benson
https://community.servicenow.com/community?id=community_question&sys_id=0276cfe1db1cdbc01dcaf3231f9619fd
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2022 05:23 AM
Hi,
You just need to update your URL as below:
var url = '/tableName_list.do?sysparm_query=id%3D' + current.user_id.toString();
This will automatically take the instance name dynamically, let me know if you have a query here.
I just tested it in my PDI and it works fine. Make sure to include the below line as well:
var url = '/tableName_list.do?sysparm_query=id%3D' + current.user_id.toString();
action.setRedirectURL(url);
Hope this helps. Please mark the answer as correct/helpful based on impact.
Regards,
Shloke
Regards,
Shloke