UI Macro to display an icon on a reference field

scot_sutton
Tera Contributor

I need assistance developing a UI Macro to display an icon on a reference field, field_1, if the current user is a member of the group specified in another reference field, field_2. I already have a UI Macro, add_me, written to populate the current user into field_1 and the code to determine if the current user is a member of the group specified in field_2 (as a Script Include, userIsMemberOfGroup). What I cannot figure out is the code to make the visibility of the icon dependent on the membership of the current user in the group specified in field_2. My jelly expertise is somewhere around the novice level so any assistance would be appreciated.

7 REPLIES 7

Hi Scot,



Just checking if you made any progress on this.



Thanks


Srini


Hi EveryOne,



I want to add custom image as an icon near to the field "contact" in the "case" form.


Is it possible to write jelly script in the macro for that?



As i'm new to script, any sample code is appreciated.


This is the jelly I am using to display an Icon next to 'Caller' field on an Incident form. This shows all the users currently in the selected company also with a provision of changing the filter:



<?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="my_company_users_${ref}"/>


  <a id="${jvar_n}"


  onclick="filterUserByCompany();"


  name="${jvar_n}"




  onmouseout="lockPopup(event)"


    tabindex="0"


>


  <img border="0" src="images/icons/group.gifx" title="${gs.getMessage('My Companies Users')}" />


  </a>



<!--<g:reference_decoration id="${jvar_n}" field="${ref}"  


  onclick="filterUserByCompany(); "  


  title="${gs.getMessage('My Companies Users')}" class="btn btn-default btn-ref icon-single_user"/>   onmouseover="popReferenceDiv(event, '${ref}', 'decoration_hover')" -->



<script>  


  function filterUserByCompany() {  


  var thefield = 'caller_id'; //Identify the reference field this should be attached to.  


  var thetable = 'incident'; //This gets whatever table you are on.  


  var lookupfield = 'lookup.'+ thetable + '.' + thefield; //Creates the lookup or reference field ID.  


  var thetarget = thetable + '.' + thefield;  




  var url = "&amp;amp;sysparm_query=company=" + g_form.getValue('company');  


  var refurl = reflistOpenUrl(thetarget, thetarget, thefield, 'sys_user', 'null', 'false', '');  


  var refurlquery = refurl + url;  


  popupOpenStandard(refurlquery, 'lookup');  


  }  


</script>  


</j:jelly>


Please mark my response as helpful or correct depending on your output.



Cheers