The Now Platform® Washington DC release is live. Watch now!

Help
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Ui Macro

monu1
Giga Contributor

Ui macro: view_context is for Creating a context menu for switching the view for both lists and forms.

As I changed the OOB program because my requirement is to hide the view context menu for itil user in ACME domain only.So I changed the code accordingly but the list view context menu has not hidden.I don't know why?

Please help me .....

My modified code is like this:  

<?xml version="1.0" encoding="utf-8" ?>

<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">

              <g:macro id="" table="" type="" first_form_section="false" />

              <j:set var="jvar_t" value="${JS:sysparm_view}" />

           

  <g:evaluate jelly="true" var="jvar_build_context">

                    var view = jelly.jvar_t;

     

                    var b = true;

                    if (RP.isPortal() || RP.isPopup() || view == "sys_ref_list")

                          b = false;

  var role = gs.getUser().hasRole('admin');

  var rol = gs.getUser().hasRole('itil');

  var dom = gs.getUser().getDomainID();

  if(rol == true &amp;&amp; role == true){

          b = true;

  gs.log('Role '+ role +'DOm ID' + dom);

  }

  else if(rol == true){

  if (dom == 'c90d4b084a362312013398f051272c0d'){

  b = false;

  gs.log('Role'+ rol +'DOm ID' + dom +'Hello');

  }}

                    b;

              </g:evaluate>

              <j:if test="${jvar_build_context}" >

              <j2:if test="$[jvar_view_changer == true]">

              <j:set var="jvar_t" value="${JS:sysparm_view}" />

              <g:evaluate var="jvar_views" object="true" jelly="true" >

                      var vm = new GlideScriptViewManager(jelly.jvar_t);

                      vm.setTable(jelly.ref);

                      vm.setTarget('${jvar_type}');

                      vm.getList(RP);

              </g:evaluate>

              <j:if test="${jvar_views.size() > 0}" >

                      var cmViews = new GwtContextMenu('${jvar_id}',${jvar_first_form_section});

        cmViews.clear();

        cmViews.setTableName('${jvar_table}');

                      var views_sa = new GwtContextMenu('context_labelMenu',${jvar_first_form_section});

                      views_sa.clear();

                      <j:forEach var="jvar_view" items="${jvar_views}" >

                            <j:if test="${jvar_view.selected=='true'}">

                                  <j:set var="jvar_img" value="images/checked.pngx" />

                            </j:if>

                            <j:if test="${jvar_view.selected!='true'}">

                                  <j:set var="jvar_img" value="images/s.gifx" />

                            </j:if>

              cmViews.addHref("${HTML:jvar_view.label}", "switchView('${jvar_type}','${jvar_table}','${JS:jvar_view.value}')", "${jvar_img}");

              views_sa.addHref("${HTML:jvar_view.label}", "switchView('${jvar_type}','${jvar_table}','${JS:jvar_view.value}')", "${jvar_img}");

                      </j:forEach>

        gcm.addMenu('${gs.getMessage('uppercase_view')}', cmViews);

              </j:if>

              </j2:if>

              </j:if>

</j:jelly>

1 REPLY 1

lorisd_avanzo
ServiceNow Employee
ServiceNow Employee

Hi Manisha,



Please have a look at List title menu in List v2



You can then try navigating in your instance to System UI -> UI Context Menus -> Filter for Name =View and open the resulting record.


You will find a Condition field that you can use to show/hide the List title menu accordingly.



I hope this helps.



Best Regards,


Loris D'Avanzo