How to get URL in server side code

Balaraju K B
Tera Expert

Hi Team,

I'm having two views let's say 'x' and 'y'.

if the page I'm opening is portal then I want to force view x and if it's standard UI (backend) then I wanted to show view y.

For this to happen I'm writing a script in the view there I want to get the URL of the standard UI in the server side code??

@Ankur Bawiskar How can I achieve this requirement any thoughts??

Thanks In Advance,

Balaraju KB

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

this line should give you the URL in server side

var url = gs.action.getGlideURI().toString();

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

10 REPLIES 10

Hi,

inside view rule script

for standard URL are you in custom scoped application?

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

@Ankur Bawiskar Yes I'm in custom scoped application

then that won't give you the URL and will break

for standard UI you can use view rules on that table

find_real_file.png

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

@Ankur Bawiskar How can i switch between two views for portal and backend standard ui

Hi,

the view rule you create will run only for Standard Native UI - Browser

refer below link for forcing view on portal

Adventures in Service Portaling: The Form Widget

Also how are users visiting the portal to see the records?

If it is using form widget then refer below link for steps

how i can set a special view for portal and special view for backend(form)?

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader