- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-25-2014 02:57 AM
Developing a new site using ServiceNow CMS and need to access the URL value inside jelly code. I see that window.location method does not work inside j or g tag in jelly instead in script tag.
Can someone please explain how to access URL value inside jelly tags?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-29-2014 02:24 AM
This piece of code seems to work fine on a demo instance:
<g:evaluate var="jvar_site_and_page" jelly="true">
var page = new GlideRecord('content_page');
page.get('${RP.getParameterValue('sysparm_sys_id')}');
page.content_site.url_suffix + '/' + page.url_suffix;
</g:evaluate>
Current URL is this:<br/>
${RP.getParameterValue('jvar_base_uri')}${jvar_site_and_page}.do
Blog: https://sys.properties | Telegram: https://t.me/sys_properties | LinkedIn: https://www.linkedin.com/in/slava-savitsky/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-25-2014 06:15 AM
This Wiki article explains how to read URL parameters in a UI Page:
Is this what you are looking for?
Blog: https://sys.properties | Telegram: https://t.me/sys_properties | LinkedIn: https://www.linkedin.com/in/slava-savitsky/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-25-2014 06:37 AM
Hi Slava, I have not used a UI page yet and proceeding with dynamic pages. And, in a dynamic page, if I use window.location within script tag I am able to access the URL but cannot pass it to a Jelly variable.
Therefore, as an alternate I started checking if I can access the URL in a similar way within jelly tags but that does not work. Once, I am able to get the URL value within jelly tags, then I will proceed with split.
Brgds, AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-25-2014 07:32 AM
You can use the RP object to return the url as detailed in this kb article:
http://wiki.servicenow.com/index.php?title=Extensions_to_Jelly_Syntax#RP
${RP.getReferringURL()} would return the url that got you to the page.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2014 02:36 PM
Hello Brad,
Thank you for showing your interest. I tried using the option you suggested but I come up with "view_content.do" instead of actual URL value.
Let me explain what I did and what I am expecting.
1. I have created a sample site using CMS named as "windowshopping" with a URL suffix as "shop".
2. Created a page as "main page" with URL suffix "main" and set it as the homepage of this site.
3. Created a dynamic block wherein I use below code in g:evaluate for accessing the URL and linked with "main page".
====================
var gr = "${jvar_RP.getReferringURL()}";
====================
Therefore, now whenever I access https://sandbox.service-now.com/shop, I want this URL value in my variable "gr" but it stores "view_content.do".
Please check if you can assist further.
Brgds, AM