How do I use g_form with Jelly in UI macro

Woz
Tera Contributor

Hello,

I am trying to add some a CSS header to a task form.

I have created a formatter and an UI macro.

I can get the CSS to work ....

<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">

    <div class="jumbotron">
        
        <h2>This CSS formatter</h2>
            
    </div>
</j:jelly>

find_real_file.png

My question is for the next part is for the next part I want to display CSS formatted data but cant find info for how to put the syntax together

I assume its something like this but I who knows? Can I display variables ? Is there any resources I Cna look at of how I can add some CSS flare to change forms

 

<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">

    <div class="jumbotron">
        <script>
            var chgNumber = g_form.getElement('number');
            var chgtype = g_form.getElement('type');
        </script>
        
        //not sure w
        <h2>The change numebr is ... $chgNumber </h2>
        <h2>The change numebr is ... $chgtype </h2>
            
    </div>
</j:jelly>

 

1 ACCEPTED SOLUTION

Hi,

 

I think g_form wouldn't work on ui macro.

Follow below approach;

 <h2 id ="message1"></h2>

 <h2 id ="message2"></h2>

Write an onload client script.

document.getElementById("message1").innerHTML = g_form.getElement('number');

document.getElementById("message2").innerHTML = g_form.getElement('type');

View solution in original post

6 REPLIES 6

Hi,

I am sorry, I mistakenly pasted g_form.getElement('number');.

Please do not use g_form.getElement('number').value; instead use g_form.getValue('number') as a art of best practice. Refer https://docs.servicenow.com/bundle/kingston-application-development/page/app-store/dev_portal/API_reference/GlideForm/concept/c_GlideFormAPI.html

Mark Endsley
Tera Guru

You actually can use g_form in a UI Macro

https://www.youtube.com/watch?v=ivP3bl7r0Ws