Thank you for your feedback.
Form temporarily unavailable. Please try again or contact docfeedback@servicenow.com to submit your comments.

Run UI scripts

Log in to subscribe to topics and get notified when content changes.

Run UI scripts

Follow these guidelines when running UI scripts.

To run a UI script on a form, create a formatter. In the associated UI macro, include a g:requires tag and specify the name= parameter as the name of the UI script followed by the .jsdbx extension. Add the formatter on the form view.

This code ensures that the definitions and results of the UI script are immediately available in the browser.

<?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>

To run a UI script from HTML code, use the <script> tag and specify the src= argument as the name of the UI script followed by the .jsdbx extension. For example, include the UI script named CoolClock with this code:

<script language="javascript" src="CoolClock.jsdbx" />
Feedback