UI Action to open a URL

pennieturner
Mega Guru

Hi, Im trying to get my form link UI Action to open a URL, where the end of the URL name changes dependant on whats in a field on the form.

I can get it open, but, unfortunately Im struggling with the passing the number to the end of it.

The field on the form is called u_project_no.   Its a string.

Heres what I have so far:

function showGoogleSite() {

  var url = new GlideURL('https://sites.google.com/a/rentokil-initialsites.com/' +'current.u_project_no');

  var w = getTopWindow();

  var newWindow = w.open(url.getURL(), "_blank");

  newWindow.focus();

  return false;

}

Im not hot on Javascript, but Im trying!   Can anyone help please?

Thank you in advance

1 ACCEPTED SOLUTION

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hi Pennie,



Please try the below script and let me know the outcome.


function showGoogleSite() {


var Projno = g_form.getValue('u_project_no');//Gets the current project no


alert(Projno) //Just for testing purpose to see if the value is passed


var url = new GlideURL('https://sites.google.com/a/rentokil-initialsites.com/'+Projno);


var w = getTopWindow();


var newWindow = w.open(url.getURL(), "_blank");


newWindow.focus();


return false;


}


View solution in original post

9 REPLIES 9

Thanks Pennie for the update.


dan.bruhn..Can you please help.


All,



I went ahead and updated the discussion to reflect correct answer.



Thanks,


Community Alums
Not applicable

Hi Pradeep,


How to get the url from a sys_property and utilize the same in UI action?



var url = new GlideURL('https://sites.google.com/a/rentokil-initialsites.com/'+Projno); --> I don't want to hardcode my url here



Thanks in advance


Hello Karthik,



You can fetch the value of property at server side as


Syntax : gs.getProperty('YOUR PROPERTY NAME HERE');


Reference:


http://wiki.servicenow.com/index.php?title=GlideSystem#getProperty.28String.2C_Object.29&gsc.tab=0


Community Alums
Not applicable

Thanks Pradeep, i couldn't use in client callable UI Action. Used glide ajax to get the property value and then used in UI Action