The Now Platform® Washington DC release is live. Watch now!
‎03-20-2015 10:14 AM
Hello Gurus,
is there a way to embed a UI script into a local client script ? could be on a form or as part of wizard or even catalog item... I do NOT want to use a global UI script, which would be loaded on every single page...
Cheers
Maros
Solved! Go to Solution.
‎03-20-2015 10:53 AM
Hi Maros,
For doing that, you have to follow below steps:
1. Create a UI Macro like below:
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<g2:evaluate var="jvar_stamp">
var gr = new GlideRecord('sys_ui_script');
gr.orderByDesc('sys_updated_on');
gr.query();
gr.next();
gr.getValue('sys_updated_on');
</g2:evaluate>
<g:requires name="<UI SCRIPT NAME>.jsdbx" params="cache=$[jvar_stamp]" />
</j:jelly>
2. Create a formatter specific to your form & include that in your form view.
You are ready to go now.
Source: UI Scripts - ServiceNow Wiki
‎03-20-2015 10:34 AM
Hi,
here some best practices. It could help you:
http://jylertones.com/blog/2013/05/the-right-way-to-use-jquery-with-servicenow/
Regards,
‎03-20-2015 10:53 AM
Hi Maros,
For doing that, you have to follow below steps:
1. Create a UI Macro like below:
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<g2:evaluate var="jvar_stamp">
var gr = new GlideRecord('sys_ui_script');
gr.orderByDesc('sys_updated_on');
gr.query();
gr.next();
gr.getValue('sys_updated_on');
</g2:evaluate>
<g:requires name="<UI SCRIPT NAME>.jsdbx" params="cache=$[jvar_stamp]" />
</j:jelly>
2. Create a formatter specific to your form & include that in your form view.
You are ready to go now.
Source: UI Scripts - ServiceNow Wiki
‎03-22-2015 12:46 PM
I suppose this approach will work with Catalog Items if i create a new variable of Macro type? I`ll try it out tmrw and let you know.. thanks a lot for your tip !