In a ui page , how can I access variables inside <g2:evaluate> in client script

Pragya8
Kilo Contributor

In a ui page , how can I access variables inside <g2:evaluate> in client script 

1 ACCEPTED SOLUTION

@Pragya 

you need to convert that to string

<g2:evaluate var="jvar_gr" object="true" jelly="true">

var sysparm_original = RP.getParameterValue('sysparm_original');
var sysparm_template_sysid = RP.getParameterValue('sysparm_template');

var arr = [];

var gr = new GlideRecord('sn_doc_html_template');
gr.addQuery("sys_id",sysparm_template_sysid);
gr.query();
if(gr.next())
{
gs.addInfoMessage(gr.name);

arr.push(gr.name.toString());
arr.push(gr.footnote.toString());

arr.push(gr.html_script_body.toString());
}
arr.toString();

</g2:evaluate>

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

15 REPLIES 15

Pay attention! Without  copyToPhase2="true" attribute it will not work!

I mean 

<g2:evaluate var="jvar_gr" object="true" jelly="true" copyToPhase2="true">

Tested in ROME release

@Ankur Bawiskar  could you approve my reply and edit your answer?

Also it may be helpful for all of us: ServiceNow UI Developer cheat sheet

Sorry didn't get you. Can you explain in detail?

Are you saying to make it work in ROME this attribute is required

copyToPhase2="true

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

At least in ROME it works only with copyToPhase2="true" attribute

Could you test it on your instance and edit your answer in the Accepted Solution?

We cannot edit response which is marked as correct.

But since you have mentioned the solution for Rome version; person searching for the solution will apply that.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Ok, thank you!