Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Script Include called in Jelly

davide_fais
Tera Expert

Hi ServiceNow Community,

I would call a Script Include by pressing a button. For exemple:

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

<button type="button">Script Include Execution</button>

</j:jelly>

Best Regards,

Davide.

1 ACCEPTED SOLUTION

davide_fais
Tera Expert

I've resolved in this way:



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



<button type="button" onclick="runCode()">Execution</button>



<script>


  function runCode()


  {


  var ga = new GlideAjax('NewIncludeClient');


  ga.addParam('sysparm_name','function1');


  ga.getXMLWait();


  var result=ga.getAnswer();


  alert(result);


  }


  </script>


</j:jelly>


View solution in original post

6 REPLIES 6

davide_fais
Tera Expert

I've resolved in this way:



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



<button type="button" onclick="runCode()">Execution</button>



<script>


  function runCode()


  {


  var ga = new GlideAjax('NewIncludeClient');


  ga.addParam('sysparm_name','function1');


  ga.getXMLWait();


  var result=ga.getAnswer();


  alert(result);


  }


  </script>


</j:jelly>


dilini
Giga Expert

Hi,


I have a script include "BillingUtilAjax" and UI action "popupDispList()". I need to call the script include via the UI action in jelly. I use following code, but it won't work.



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


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




<button type="button" onclick="popupDispList()">Execution</button>


<script>




  function popupDispList() {


  var ajaxQry = new GlideAjax('BillingUtilAjax');


  ajaxQry.addParam('sysparm_name','getHtmlForBillingReport');


  ajaxQry.addParam('sysparm_ritm','');


  ajaxQry.addParam('sysparm_req', g_scratchpad.requestSysId);


  ajaxQry.addParam('sysparm_today',(new Date()).toString());


  ajaxQry.getXML(ajaxResponse);



}




function ajaxResponse(response) {


  var answer = response.responseXML.documentElement.getAttribute("answer");


  var win = window.open("", '_blank');


  win.document.body.innerHTML = answer;


  win.document.title = 'Billing Form';


  win.focus();


}


  </script>