how to get current url and check using getUrlOnStack() ?

RudhraKAM
Tera Guru

Hello guys,

 

can some one please help me how to check the current url and then redirect base on that to a specific view.

getUrlOnStack()

 

If the user opening an RITM has no itil roles, and the requested item is from the Software Catalog, and the item is being opened from an /SSS portal url and the item is not closed incomplete, use the sp view.

 

Script: 
if (!gs.hasRole("itil") && item.sc_catalogs=="57bf1d3e13635b00602dbcaf3244b0a0" && state!="4");
view =sp;

2 REPLIES 2

Brad Tilton
ServiceNow Employee
ServiceNow Employee

Where are you running this from? If it's server side you may be able to use something like RP.getReferringURL.

Also, this post may be helpful: https://community.servicenow.com/community?id=community_question&sys_id=67240729dbd8dbc01dcaf3231f96...

Thanks Brad,,

I am checking in view rules (advance ) , we have a requirement where if the logged in user is opening the RITM from portal he should be redirected to sp view 

 

https://xyz.service-now.com/sss  is my portal link , can you please let  me know to to add this in below query ?

 

if (!gs.hasRole("itil") && item.sc_catalogs=="57bf1d3e13635b00602dbcaf3244b0a0" && state!="4");
view =sp;

 and in view rules can we check if the opened RITM is from certain catalog or not ?

-------------------------------------

can we check roles and conditions at the same time in the view rules ?