How to get current URL from UI action

saranyavs
Tera Expert

Hi,

We have a ui action in List context menu, and need to access the current URL for a requirement. Is there any OOB script to fetch the current URL in UI action. Please help.

1 ACCEPTED SOLUTION

chrisperry
Giga Sage

Hi there,

This code should work for any server-side script (including UI Actions) to get the current URL:

gs.getProperty("glide.servlet.uri") + gs.action.getGlideURI();

If this answer is helpful please mark correct and helpful!

Regards,

Christopher Perry

If this answer is helpful please mark correct and helpful!

Regards,
Chris Perry

View solution in original post

6 REPLIES 6

Sure so you could use the below code to get your sysparm variable value:

var url = "alm_hardware_list.do?sysparm_query=u_hardware_type%3DMonitor%5Einstall_status%3D6%5Esubstatus%3Davailable&sysparm_rit=1251182f1b124990f576dd31b24bcbfc&sysparm_first_row=1&sysparm_view=";
gs.info(getParameterValue('sysparm_rit'));


function getParameterValue(name) {
    name = name.replace(/[[]/, "\\[").replace(/[\]]/, "\\]");
    var regexS = "[\\?&]" + name + "=([^&#]*)";
    var regex = new RegExp(regexS);
    var results = regex.exec(url);

    return (results ? unescape(results[1]) : "");
}

Result:

find_real_file.png

If this answer is helpful please mark correct and helpful!

Regards,

Christopher Perry

If this answer is helpful please mark correct and helpful!

Regards,
Chris Perry

Drew Carpenter
Tera Expert

What's the Configurable Workspace solution for this?
gs.action.getGlideURI() doesn't work, and *.location.href only works client side.