Dynamic icons for impact field in the the incident table

ManishS14752344
Tera Contributor

So, while i am learning about scripting in ServiceNow, I was trying something. What I want is, I have three images, red.png, yellow.png and green.png. Now, I want to display one of these images based on the impact field. The change should be dynamic. I have done this using UI Macro with client script where in the Macro, I put the images and wrote an onChange client script. It is working fine. I was looking for alternative to do this only using the Macro. I found this code

<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
    <j:if test="${not empty(current.u_impact)}">
        <j:choose>
            <j:when test="${current.u_impact == '1'}">
                <img src="red.png" alt="High Impact" title="High Impact" />
            </j:when>
            <j:when test="${current.u_impact == '2'}">
                <img src="yellow.png" alt="Medium Impact" title="Medium Impact" />
            </j:when>
            <j:when test="${current.u_impact == '3'}">
                <img src="green.png" alt="Low Impact" title="Low Impact" />
            </j:when>
            <j:otherwise>
                <span>No Impact Set</span>
            </j:otherwise>
        </j:choose>
    </j:if>

</j:jelly>

This is working. So, I wanted to know if I can use all the jelly methods and functions or there are some restrictions?

Regards,
Manish Singh
4 REPLIES 4

Ankur Bawiskar
Tera Patron
Tera Patron

@ManishS14752344 

where do you wish to show the icons?

share screenshots.

Within UI macro you can use all jelly statements which are supported by ServiceNow.

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

Hi @Ankur Bawiskar,

 

Well I want to put those icons around the impact field.

ManishS14752344_0-1751862394204.png

 

 As I have already mentioned, I did this using UI Macro, Formatter and Client Script. But the code that I have pasted is not working. The main question I have is which jelly statements can be used in ServiceNow. I would like if you can provide some documentation for jelly usage in ServiceNow.

Regards,
Manish  Singh

 

@ManishS14752344 

you can check lot of OOTB UI macros which are added near field and that will help you know which all works

take example of this which is added to caller_id field of incident table

UI macro - user_show_incidents

AnkurBawiskar_0-1751867714235.png

 

If my response helped please mark it correct and close the thread so that it benefits future readers.

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