conditional rendering of UI macro
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2025 12:02 AM
Have a flag on the form. It will be true if the Requester email id exists in sys user table. I am trying to display the information icon that is placed next to 'Requester email id' based on the value from the flag. If the flag is true display the info icon else dont display.
here is the UI macro
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<div style="display: flex; align-items: center;">
<script>
var cgcflag = g_form.getValue('u_cgc_flag');
if (cgcflag == true) {
document.write('<img src="cgc_info.jpg" alt="Manager Info" style="cursor:pointer; height: 20px; vertical-align:middle;" onclick="openManagerInfo()" />');
}
function openManagerInfo() {
var req_emailid = g_form.getValue('u_requester_email_id');
alert('req_emailid' + req_emailid);
var dialog = new GlideModal('cgc_Manager_Info', false, 400, 400);
dialog.setTitle('Leader Information');
dialog.setPreference('sysparm_req_email', req_emailid);
alert('sysparm_req_email' + req_emailid);
dialog.render();
}
</script>
</div>
</j:jelly>
code is working without the below lines.
var cgcflag = g_form.getValue('u_cgc_flag');
if (cgcflag == true) {
document.write('<img src="cgc_info.jpg" alt="Manager Info" style="cursor:pointer; height: 20px; vertical-align:middle;" onclick="openManagerInfo()" />');
}
can we use the conditional rendering ? Appreciate the help.