How can I grab the current URL from a UI action?

Adam Robbins1
Mega Guru

Hi,

How can I grab the URL of the current page through a UI action?

I have created a UI action that can be a button on a form and also accessible through the list view as a List choice so multiple records can have this applied at the same time.

I was using current.getLink(), but it doesn't provide the needed behavior when executed from a list view.  If using it on multiple records from a list view, I'd like the action.setRedirectURL to go back to the list view rather than pulling up the last record that was updated.

I have tried using parent.window.location.href, but no luck. 

Thanks,

Adam

1 ACCEPTED SOLUTION

Adam Robbins1
Mega Guru

I just searched scripts for other UI actions and found that this works: GlideSession.get().getStack().bottom();

View solution in original post

5 REPLIES 5

Aman Kumar S
Kilo Patron

You can follow below article:

How to get the URL in Server Side

 

Feel free to mark correct, If I answered your query.

Will be helpful for future visitors looking for similar questions 🙂

Best Regards
Aman Kumar

I tried the link, but unfortunately I am getting back undefined for both 

gs.action.getGlideURI()

and

gs.getSession().getUrlOnStack()

dmathur09
Kilo Sage
Kilo Sage

Hi Adam,

Can you refer - https://community.servicenow.com/community?id=community_question&sys_id=e61dec0adb600c10190dfb2439961959

Regards,

Deepankar Mathur

Adam Robbins1
Mega Guru

I just searched scripts for other UI actions and found that this works: GlideSession.get().getStack().bottom();