Ankündigung

Einklappen
Keine Ankündigung bisher.

How to check the current logged user belongs to Group A or Group B ?

Einklappen
X

How to check the current logged user belongs to Group A or Group B ?

Einklappen
  • Filter
  • Zeit
Alles löschen
neue Beiträge

  • How to check the current logged user belongs to Group A or Group B ?

    I have few users with operator role in (Group A) and with administrator role in (Group B). I want to show different pages on click of a button for the users depending upon whether he is in Group A or Group B. Is there a possibility in Javascript / Velocity to check which Group belonging user is currently logged in ?
    Thanks

  • #2
    Hello,

    you could use this example from the library (Velocity):
    Code:
    #set($groupGuids = ['EF16F15EDA8562E19D7CD56BF2E43001F119193C', '47DD42CF4203EFDC7B1596E0158BB5B1E810D583']) ##define the groups
    
    ##Returns true, if $User is member of at least one group, which is defined by its GUID in $groupGuids
    #if ($userMembership.intersects($groupGuids))
        ##here you can show or hide the group or button
        #set($show_buttoncontrol1XYZ = true)
    #else
        #set($show_buttoncontrolXYZ = false)
    #end
    Good luck!

    Kommentar


    • #3
      Thanks: I will give it a try. Can you please also let me know, how i can get a user selected value from a drop down list existing on a view page (Ansichtseite) in Velocity. I am using
      #set($div = $!DC.getValueHolder('dropdowncontrol5321DA91').get Value()) and also tried using $DC.getValueHolderByFieldGuid('dropdowncontrol5321 DA91').getValue() but i am not able to get the value selected from user.

      Kommentar


      • #4
        Velocity is a server-side language, so you won't be able to get a currently selected value from a dropdown.
        You have to use Javascript (client-side), e.g.:

        Code:
        Browser.getValue(getElement("<guid>"));

        Kommentar


        • #5
          I would like to build a query based on the user selected value in the drop down list. Eg: I would like to read the user selected value from the drop down list like #set($Nr= $!DC.getValueHolder('dropdowncontrolXYZ').getValue ()) and then build a query like #set($stat = $PreparedQuery.prepare($DbConnection, "SELECT A1, A2 FROM DATAGROUP('A53CBCE10C8FA03AC5B28BF78B5D2F756DE0C53 0') WHERE Nr=?") and $statement.setInt(1, $Nr). Unfortunately i am not able to read the Nr Value.

          Kommentar

          Lädt...
          X