Ocultar campo en editviewsdef en función de un valor del CurrentUser

Buenas.

Tengo un listener en un js

document.addEventListener( 'DOMContentLoaded', function() {
   showHidePanelContacts();
});

Como podría pasarle un valor del CurrentUser para ocultar un campo de edirviewdet?

O como se haría sin el listener. El listener lo tengo para ocultar ciertos paneles en el detalviewdefs en función de ciertos valores de campos.

Un saludo.

Parents
  • Hi Oscar 

                Do you want to show or hide contacts sub panel based on current user or what? thoda english mein samjovo bhai...

    Regards

    Sidhu

  • Hola Óscar del Río,

    Te contesto en inglés, así el resto de la comunidad puede entender mejor la respuesta.

    I would recommend you doing this through an after_ui_frame LogicHook triggered on the module you want to make the customization.

    The code of the LogicHook would be like the following:

    class LoadUserInEditView {

       function loadUserRolesInEditView( $bean, $event, $arguments ) {

           if( !$bean ) {
             return;
           }

           global $current_user;

           $department = $current_user->department;

           $departmentHtml = '<input type="hidden" style="display: none" id="user_department">' . $department . '</input>';

           echo $departmentHtml;

       }

    }

    This would set in the DOM a hidden input element which will store the department of the current user.

    Then in your javascript:

    document.addEventListener( 'DOMContentLoaded', function() {
       showHidePanelContacts();

       var department = $('#user_department').html();

       if( department !== 'my_desired_department' ) {
          $('#field_to_hide').hide();
       }
      
    });

    Espero que te sirva. Cualquier duda me dices!

    Saludos/Regards,

    David.

  • Hello Óscar del Río,

    As Francesca Shiekh mentioned above, if you can work with Roles, then you should be able to set this field hidden using the field level permissions.

    So, you should add all the users that DON'T have the Department = "Value1" to a role. Within that role, access to the Contacts fields ( Role settings  ) and set your field to None. That would hide this field for all the users on this role while all other users ( Department = "Value1" ) would be able to see it.

    I hope it helps but please let me know if you have any questions.

    Regards,
    Francesc del Moral
    Technical Support Engineer

Reply Children