Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Display the current URL of my servicenow instance from a catalog item

caroleb_atrice
Tera Contributor

Hello everyone,

I create a custom variable on my catalog item with the script below which open a ServiceNow page. I want to modify that
script to display the current URL of my instance.

 

Tab Default value :

{
"widget": "widget-link-button",
"href": "https://docs.servicenow.com/bundle/orlando-it-service-management/page/product/service-catalog-management/reference/r_VariableTypes.html",
"button_text": "SAPSubmit",
"color": "primary"
}


I have the following script on a ui page who help me do display the current URL but I want to display this current URL from the catalog item.

 

<script>
alert(window.location.href);
</script>


How can I modify my script on catalog custom variable to display the current ServiceNow URL ?

Thanks in advance,
Carole

 

 

1 ACCEPTED SOLUTION

Hi,

Try creating new widget something like mentioned in the below image

find_real_file.png

 

and link the widget to your catalog item using custom variable type

 

find_real_file.png

 

Regards,
Mahesh

View solution in original post

4 REPLIES 4

Mahesh23
Mega Sage

Hi,

make use of below property which returns the current ServiceNow URL

gs.getProperty('glide.servlet.uri');

 

find_real_file.png

Regards 

Mahesh

caroleb_atrice
Tera Contributor

Thanks for your answer.

How can I modify the following script to display the current servicenow URL ?

 

Tab "Default value" : (On a custom catalog item variable)

{
"widget": "widget-link-button",
"href": "https://docs.servicenow.com/bundle/orlando-it-service-management/page/product/service-catalog-management/reference/r_VariableTypes.html",
"button_text": "SAPSubmit",
"color": "primary"
}

Hi,

Try creating new widget something like mentioned in the below image

find_real_file.png

 

and link the widget to your catalog item using custom variable type

 

find_real_file.png

 

Regards,
Mahesh

Sai Kumar B
Mega Sage

@carolebéatrice 

try the below

Tab "Default value" : (On a custom catalog item variable)

{
"widget": "widget-link-button",
"href": gs.getProperty('glide.servlet.uri')
"button_text": "SAPSubmit",
"color": "primary"
}