Calling Script Include in UI Macro and display return value

reginabautista
Kilo Sage

Hi guys,

I am doing some integration with PagerDuty and getting the On Call Rota using API. I would like to display the retrieved value on the form via a UI Macro.

Looking at   the logs, I know the script include is being called and value being returned, however I am unable to display it on the form. This is what I have so far. Could you please let me know what am I missing? I haven't done any jelly scripting before so I find it challenging.

<tr>

    <td>On Call Manager</td>

    <g2:evaluate var="jvar_your_var" jelly="true">

  var your_var= BFPagerDuty_RetrieveOnCallRotaMgr.retrieveOnCallRotaMgr();

    <p>$[jvar_your_var]</p>

</g2:evaluate>

  </tr>

1 ACCEPTED SOLUTION

What is the API you are calling? What is the name of the Script Include and method? From your script I don't see where you instantiate an object of the Script Include class. If I knew the API you are talking about I would know exactly what script you need but I would expect something like this should do the trick:



<tr>


    <td>On Call Manager</td>


    <g2:evaluate var="jvar_your_var" jelly="true">


var BFPagerDuty_RetrieveOnCallRotaMgr = new BFPagerDuty();


BFPagerDuty_RetrieveOnCallRotaMgr.retrieveOnCallRotaMgr();


</g2:evaluate>


    <p>$[jvar_your_var]</p>


  </tr>



You might want to review these free trainings about Script Includes and Jelly:


https://developer.servicenow.com/app.do#!/training/article/app_store_learn_coding_helsinki_c_Module6...


https://developer.servicenow.com/app.do#!/training/article/app_store_learn_coding_helsinki_c_Module6...


TechNow Episode 1 | ServiceNow Jelly Scripting Part 1 of 3 - YouTube


View solution in original post

9 REPLIES 9

What is the API you are calling? What is the name of the Script Include and method? From your script I don't see where you instantiate an object of the Script Include class. If I knew the API you are talking about I would know exactly what script you need but I would expect something like this should do the trick:



<tr>


    <td>On Call Manager</td>


    <g2:evaluate var="jvar_your_var" jelly="true">


var BFPagerDuty_RetrieveOnCallRotaMgr = new BFPagerDuty();


BFPagerDuty_RetrieveOnCallRotaMgr.retrieveOnCallRotaMgr();


</g2:evaluate>


    <p>$[jvar_your_var]</p>


  </tr>



You might want to review these free trainings about Script Includes and Jelly:


https://developer.servicenow.com/app.do#!/training/article/app_store_learn_coding_helsinki_c_Module6...


https://developer.servicenow.com/app.do#!/training/article/app_store_learn_coding_helsinki_c_Module6...


TechNow Episode 1 | ServiceNow Jelly Scripting Part 1 of 3 - YouTube


reginabautista
Kilo Sage

Thanks Balaji, it's coming back as blank on the form.



here's what I get in the log, so i know for sure there is a returned value..



03-05-2017 16:07:26


bautistar_admin Information onCallMgr=John Cha


Try this way then,



<tr>


    <td>On Call Manager</td>


    <g2:evaluate var="jvar_your_var" jelly="true">


  var your_var= BFPagerDuty_RetrieveOnCallRotaMgr.retrieveOnCallRotaMgr();


                your_var


</g2:evaluate>


    <p>$[jvar_your_var]</p>


  </tr>



or


<tr>


    <td>On Call Manager</td>


    <g2:evaluate var="jvar_your_var" jelly="true">


  var your_var= BFPagerDuty_RetrieveOnCallRotaMgr.retrieveOnCallRotaMgr();


                your_var


</g2:evaluate>


   


<script>


          $[jvar_your_var];


</script>


  </tr>


reginabautista
Kilo Sage

thanks balaji..but no luck!


reginabautista
Kilo Sage

Hi Matthew that did the trick. I have to instantiate the script include first before calling the function. Thanks for your help!