call a function from jelly g:evaluate

karanshah
ServiceNow Employee
ServiceNow Employee

How do I create a function that jelly g:evaluate can call to avoid repeating code?

<g:evaluate var="jvar_caseGr">

              var url = '${sysparm_url}';

              commonMethod(url);

</g:evaluate>

<g:evaluate var="jvar_abc">

              var url = '${sysparm_abc}';

                commonMethod(url);

  </g:evaluate>

<g:evaluate var="jvar_test">

              var url = '${sysparm_test}';

                commonMethod(url);

</g:evaluate>

commonMethod(url) {

...some code

}

1 REPLY 1

adiddigi
Tera Guru

You write a Script Include, and call it from the Evaluate.



convert commonMethod to a Script Include class and use it.