Skip to main content
kavyam0002
May 2, 2022
Solved

formLayout

  • May 2, 2022
  • 3 replies
  • 1 view

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

    Best answer by nareshs945

    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

    May 2, 2022

    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

    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
    May 3, 2022

    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".