How can I pass arguments from ui action to ui page

kjmauriello
Mega Expert

I am opening a UI Page from a UI Action (client=true) like this:

window.location = 'ui_page_process.do?name=jello_world' + parmList;

parmList is 'sysparm_incident={sys id of incident}


UI Page:

I expect to retrieve the parameter and display it, I will use it later for processing and display purposes.   I used the example in this article: Passing a Parameter through url to Query in UI Page

<?xml version="1.0" encoding="utf-8" ?>

<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">

<g:evaluate var="sysparm_incident">

  var sysparm_incident = RP.getParameterValue("sysparm_incident");

  sysparm_incident;

</g:evaluate>

incident: ${sysparm_incident}<br/>

</j:jelly>


the word incident is disiplayed but no sys_id.

I turned on debug and it looks like the sys_id is being passed in properly:

      21:22:50.876: #45645 /ui_page_process.do Parameters ------------------------- sysparm_incident=d71f7935c0a8016700802b64c67c11c6 name=jello_world

I tried with and without quotes, different variable names and I can't seem to get the parameters value.


I also tried using this from the Wiki with no luck: <j:set var="jvar_incident" value="${sysparm_incident}" />


Any help with this would be greatly appreciated.

1 ACCEPTED SOLUTION

adiddigi
Tera Guru

You are mixing JEXL and Jelly Variables with `sysparm`. You have to change specifically at two places and it works fine.



<?xml version="1.0" encoding="utf-8" ?>


<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">


<g:evaluate var="jvar_incident">


  var sysparm_incident = RP.getParameterValue("sysparm_incident");


  sysparm_incident;


</g:evaluate>


incident: ${jvar_incident}<br/>


</j:jelly>



URL to be used to call the UI page :



window.location = 'ui_page_process.do?name=jello_world&sysparm_incident=1235454555';


View solution in original post

4 REPLIES 4

adiddigi
Tera Guru

You are mixing JEXL and Jelly Variables with `sysparm`. You have to change specifically at two places and it works fine.



<?xml version="1.0" encoding="utf-8" ?>


<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">


<g:evaluate var="jvar_incident">


  var sysparm_incident = RP.getParameterValue("sysparm_incident");


  sysparm_incident;


</g:evaluate>


incident: ${jvar_incident}<br/>


</j:jelly>



URL to be used to call the UI page :



window.location = 'ui_page_process.do?name=jello_world&sysparm_incident=1235454555';


kjmauriello
Mega Expert

I copied your suggestion, and it still does not display the parameter???



current UI Action:


onclick = setAppointment()



function setAppointment() {


  try {


  var parmList = '&sysparm_incident=' + g_form.getUniqueValue();


  window.location = 'ui_page_process.do?name=jello_world&sysparm_incident=1235454555';


  } catch(e) {


  alert('ERROR: ' + e);


  }


}



current UI Page:


<?xml version="1.0" encoding="utf-8" ?>


<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">


<g:evaluate var="jvar_incident">


  var sysparm_incident = RP.getParameterValue("sysparm_incident");


  sysparm_incident;


</g:evaluate>


incident: ${jvar_incident}<br/>


</j:jelly>


Not sure, might be something wrong with the name of UI Page. I just created a UI Page and an UI Action in https://demo018.service-now.com/login.do?



Name of the UI page is : temp_uip and name of the button is temp, and it's on Incident table. Works just fine.


I see what the problem was.



I was calling the ui_page_process.do and passing name ans the ui page name


window.location = 'ui_page_process.do?name=jello_world&sysparm_incident=12345'



the proper way to call is the ui page name.do then the parms


window.location = 'jello_world.do?sysparm_incident=1235454555';



thank you for your assistance