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

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;


}


Thats brillant thank you! That worked!



Thanks so much for your help


Hi Pennie,



Thanks for the update.


Would you mind marking my response as correct and close the loop if that answers your question.


I don't seem to be able to mark it as correct, theres no button there, I tried to change my original post but I can't see the tick box to say mark it as a question