Skip to main content
kavyam0002
Brainy
May 2, 2022 1:15 PM UTC
Solved

formLayout

Hi

i need to show set of buttons to a particular users and need to show other sets of buttons for some users how can i achieve this

am using formLayout

i have written like this but this is giving error, let me know the correct way to write

    Inspiring
    May 2, 2022 1:27 PM UTC

    Hi,

    You can use show when condition available in button widget. Add your conditions for each button.

    a!formLayout(
      contents: {
        
      },
      buttons: {
        a!buttonLayout(
          primaryButtons: {
            a!buttonWidget(
              showWhen: a!isUserMemberOfGroup(
                loggedInUser(), cons!CR_GRP_BOARD_OF_DIRECTORS_GROUP
              ),
              label: "Button 1"
            ),
            a!buttonWidget(
              showWhen: a!isUserMemberOfGroup(
                loggedInUser(), cons!CR_GRP_BOARD_OF_DIRECTORS_GROUP2
              ),
              label: "Button 2"
            )
          }
        )
      }
    )

    3 replies

    Inspiring
    May 2, 2022 1:27 PM UTC

    Hi,

    You can use show when condition available in button widget. Add your conditions for each button.

    a!formLayout(
      contents: {
        
      },
      buttons: {
        a!buttonLayout(
          primaryButtons: {
            a!buttonWidget(
              showWhen: a!isUserMemberOfGroup(
                loggedInUser(), cons!CR_GRP_BOARD_OF_DIRECTORS_GROUP
              ),
              label: "Button 1"
            ),
            a!buttonWidget(
              showWhen: a!isUserMemberOfGroup(
                loggedInUser(), cons!CR_GRP_BOARD_OF_DIRECTORS_GROUP2
              ),
              label: "Button 2"
            )
          }
        )
      }
    )

    arulk0002
    Inspiring
    May 3, 2022 1:23 AM UTC

    Hi,

    Better way to achieve create a showwhen parameter in the particular button. With respect create an expression rule give either isusermemberofgroup(), a!isUserMemberOfGroup() then use the expression rule wherever in the interface button showwhen parameter

    Ex: a!isUserMemberOfGroup(groupname: "HR")

    richardm900458
    Inspiring
    May 3, 2022 7:47 AM UTC

    hi kavyamutter,

    some basic rules:
    1.) It is not possible to create a If clause around a function parameter
    if(buttons:)    -> buttons: if() 

    2.)as already mentioned to create logic to display something, there is for most interface functions a parameter called "showWhen".