How to access a URL inside g:evaluate tag in Jelly

antonymirza
Tera Expert

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?

1 ACCEPTED SOLUTION

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


View solution in original post

12 REPLIES 12

Hi Alex,


You are right. Thanks for pointing this out!


johnram
ServiceNow Employee
ServiceNow Employee

The ServiceNow Wiki content is no longer supported. Updated information about this topic is located here: Extensions to Jelly Syntax



Visit http://docs.servicenow.com for the latest product documentation


Patrick Schulte
Kilo Guru

If you just need the URL suffix of the current page you can also do something like:



<g:evaluate>


current_page.getURLSuffix();


</g:evaluate>



You can also take a look here for further methods of the current_page object: current_page Object Type Confusion


With current_page.getSiteID() you should then also be able to query the url_suffix of the content_site table if that is necessary.