Is there a way to use currentinstance to redirect a user instead of a hardcoded hyperlink?

asd22
Tera Contributor

Hello, i have a button that you press to log in and it takes you to the login page. Currently i just have it in the html body like so :

<center style="margin-top:15px;">${sh_login_register}/<a class="large-link" href="https://dev.service-now.com/portal1/user_registration_request.do?sys_id=-1&sysparm_view=ess&sysparm_origin=portal1">${sh_loginpage_registernewuser}</a></center>

 

Is there a way where i dont need to hardcode in the link and just have its dynamic after wich instance your in (prod, test, dev)?

 

2 REPLIES 2

dgarad
Giga Sage

HI @asd22 

Instead of using the URL as hardcoded, you can use the parameters written after the "/"
For example:
dev11111.service-now.com/id=page_name&sys_id=1234567890123...
Use
/id=page_name&sys_id=1234567890123...

This will make your URL dynamic.

If my answer finds you well, helpful, and related to the question asked. Please mark it as correct and helpful.

Thanks
dgarad

Community Alums
Not applicable

Hi @asd22 ,

 

Use this OOTB system property to get instance name.

 

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

 

 or

 

gs.getProperty('instance_name')

 

Your modified code:

<center style="margin-top:15px;">${sh_login_register}/<a class="large-link" href=" '+gs.getProperty('glide.servlet.uri')+' "portal1/user_registration_request.do?sys_id=-1&sysparm_view=ess&sysparm_origin=portal1">${sh_loginpage_registernewuser}</a></center>

 

If my answer helped you in any way, please mark it as helpful or correct.