New UI, RP.getReferringURL() - not working ?

Julian Poyntz
Tera Contributor

just trying out the new UI, and a context menu update we have is causing a problem

There was a line

var urlpath = RP.getReferringURL(); 

that used to get us the path, but now seems to return null and throws the rest of the menu off.  Changing that value for a hard coded entry and it all works, so I know it is that line.

What do we use in the new UI in a context menu to get the referring URL ?

 

Thanks in advance

5 REPLIES 5

-O-
Kilo Patron
Kilo Patron

Could you share where exactly is that call used?

It is in the sys_ui_macro - context_form_header

I don't have that in the OOB version.

Anyway, that is not a method that would give you the path of the resource requested. It will return the path - just as the name says - of the referring URL. Say the page that includes this header is opened from a link, there will be no referring URL. And the returned value will be - of course - null. It is expected that is how it will work.

I'm not sure what you want to do with that information, but if it is really the referring URL that you are interested in, you must change the solution to handle null values. If it is the URL of the current request that you are interested in, you can obtain the current request's url by running:

GlideTransaction.get().getURL();

E.g. running

var a = GlideTransaction.get().getURL();

gs.debug(a);

in Scripts - Background prints:

*** Script: [DEBUG] /sys.scripts.do

Not sure how you do not have it as it how the dropdown menu from the top of a page is generated.
https://dev123.service-now.com/nav_to.do?uri=sys_ui_macro.do?sys_id=2ff1c56ca9fe3dba014340c4697b5088

The code works fine, has done for many revisions and UI versions.  It is just that my client enabled the new UI experience and it throws a complete wobbler, so complete that the instance is unusable due to the error that is generated.

The code in question adds a menu to the drop menu with various options based on the URL from the current page (yes, I can use a UI Action,  but OOB it does not support a "menu" structure and to do that you need to do some DOM work - there is a nice article on the community somewhere that facilitates this)

the getReferringURL is also found in the ui macro attachment_entry

https://dev123.service-now.com/nav_to.do?uri=sys_ui_macro.do?sys_id=2c43bf710a0a0b39001e825b1ea82b4f