Tuesday, 22 August 2023

Servicenow jelly g: evalaute vs g2:evaluate, j vs j2 ${} vs $[]

 ServiceNow Jelly cheat sheet:


https://gist.github.com/nguyen0096/4d7f239689be0aac559c75b73acfdcb2


Servicenow Jelly y g: evalaute vs g2:evaluate, j vs j2 ${} vs $[]



https://www.servicenow.com/community/developer-forum/ui-page-html-section-difference-between-lt-g-gt-and-lt-g2-gt/m-p/1819158

Jelly g j vs g2 j2

- g sections are evaluated. Output is cached.

Use ${} to evaluate expressions in the HTML portion. Use this if it's a value that is going to be constant on each page display. Using this when you should use g2 will mean that values related to the record (or whatever else is varying) won't change as you load the page.


- g2 sections are evaluated, output is sent to client (browser, etc.)


Use $[] to evaluate expressions in the HTML portion. Use this if it's a value that is going to change on each page display, using this when you don't need to will make the display of the page slower.


// This is treated as code and returns the results

<g:evaluate var="jvar_mynames" jelly="true">

    var gr= new GlideRecord('u_platfs');

    gr.query();

    gr.next();

    gr.sys_id;

</g:evaluate>



output phase 1:


${jvar_mynames}


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

    var gr= new GlideRecord('u_platfs');

    gr.query();

    gr.next();

    gr.sys_id;

</g2:evaluate>



output phase 2:


$[jvar_mynames]

No comments:

Post a Comment