Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

Hiding a UI Macro based on Field Data

ewok
Giga Contributor

I have created the following UI Macro that displays on a particular field in a form. The macro works great and provides the custom link to a 3rd party website and appends the field data onto the button link. However I want to hide the button if the data in a specific field is null. I have tried a few things based on some searching such as a Jelly If statement and even some if statements in the script section of this UI Macro. However none have proved to be successful. Any Suggestions? I am running Kingston Patch 4 currently. 

---Current UI Macro---

<?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:set var="jvar_n" value="ip_rep_${ref}"/>
<span id="${jvar_n}" onclick="ip_rep('${ref}')" title="IP Reputation" alt="IP Reputation" tabindex="0" class="btn btn-default icon-search">
<span class="sr-only">IP Reputation</span>
</span>
<script>
function ip_rep(reference){
window.open('https://www.talosintelligence.com/reputation_center/lookup?search=' + encodeURI(g_form.getValue('u_source_ip_s')));
}
</script>
</j:jelly>

 

----Jelly IF-----

<j:if test="${u_source_ip_s != null}">
<j:set var="jvar_n" value="ip_rep_${ref}"/>
<span id="${jvar_n}" onclick="ip_rep('${ref}')" title="IP Reputation" alt="IP Reputation" tabindex="0" class="btn btn-default icon-search">
<span class="sr-only">IP Reputation</span>
</span>
</j:if>

----Script IF----

function ip_rep(reference){
if (g_form.getValue('u_source_ip_s') != null){
window.open('https://www.talosintelligence.com/reputation_center/lookup?search=' + encodeURI(g_form.getValue('u_source_ip_s')));
}
}

1 ACCEPTED SOLUTION

Hi,

I have tested g_form works fine in UI Macro.

Try thisalong with previous onChange.

var sysID = g_form.getValue('u_source_ip_s');

if(!sysID){

visibility = 'hidden';

}

 

View solution in original post

10 REPLIES 10

CJB
Tera Expert

Hi @ewok. Can you help me?