Default value in the group picker field should not be removed

Certified Associate Developer

Hi Team,

I have a group Picker field and there is a condition that if mkv = 'mk-3475' by default it should select a group called Keytruda writers. The users who is working on this interface cannot remove this group but they can add more groups along with this. 

Can some one help how I can achieve this.

a!pickerFieldGroups(
  required: true,
  label: "Assignee(s)",
  helpTooltip: if(
    and(
      or(
        ri!lrrf['recordType!{a8fd253d-0e45-428b-af5f-cdd4c2b27a87}RGRACSLBL LRRF.fields.{57e16ccd-ed38-46b5-9fb7-8f5cfca177c9}reviewType'] = cons!RGRACSLBL_LRRF_REVIEW_TYPES[1],
        ri!lrrf['recordType!{a8fd253d-0e45-428b-af5f-cdd4c2b27a87}RGRACSLBL LRRF.fields.{57e16ccd-ed38-46b5-9fb7-8f5cfca177c9}reviewType'] = cons!RGRACSLBL_LRRF_REVIEW_TYPES[2]
      ),
      ri!lrrf['recordType!{a8fd253d-0e45-428b-af5f-cdd4c2b27a87}RGRACSLBL LRRF.fields.{2ebc42d8-fe25-490b-879a-dcf755894066}country'] = cons!RGRACSLBL_EUROPEAN_UNION
    ),
    cons!RGRACSLBL_CONS_LRRF_GLL_HELPER,
    {}
  ),
  groupFilter: if(
    ri!lrrf['recordType!{a8fd253d-0e45-428b-af5f-cdd4c2b27a87}RGRACSLBL LRRF.fields.{296074dc-1b66-4d21-a91f-0cc9c8a771f2}mkv'] = cons!RGRACSLBL_KEYTRUDA,
    a!hiddenField(
      value: cons!RGRACSLBL_GROUP_KEYTRUDA_WRITERS
    ),
    {}
  ),
  value: rule!APN_distinct(ri!assignees),
  saveInto: a!save(
    ri!assignees,
    rule!APN_distinct(save!value)
  ),
  
)

  Discussion posts and replies are publicly visible

Parents
  • So if I have understood you want to add that 1 group by default in ri!assignees if it matches the condition and also one of the groups selected by user. 

    While user is searching and selecting the group they want, you can run a condition in saveinto part to check if it matches your condition and 
    then you add that group in your rule input. 

    a!localVariables(
      local!assignees,
      {
        a!pickerFieldGroups(
          label: "Group Picker",
          labelPosition: "ABOVE",
          saveInto: {
            local!assignees,
            if(
              true(),
              a!save(
                local!assignees,
                union(
                  append(local!assignees, togroup(465)),
                  append(local!assignees, togroup(465))
                )
              ),
              null()
            )
          },
          value: local!assignees,
          validations: {},
          
        )
      }
    )

  • 0
    Certified Associate Developer
    in reply to Kumar Agniwesh

    Thanks for the reply.

    the user shouldnot be able to remove the default group which has been added when the condition is met.

    for example, here the condition has met and the default group is added in the picker field. Now if I click on 'x' mark I can remove that group. but what my requirement is the user should not be able to remove this default group. 

    Can we achieve this ?

  • Well I was able to achieve it to some level, the group keeps getting added even if they remove it. Also you can add the group by default after checking the condition while defining the variable. 


  • 0
    Certified Senior Developer
    in reply to p2005

    As an Extension to Kumar's Solution, you can also add a validation in code like :

    This way we show an error message in case the particular group is removed.

    a!localVariables(
      local!assignees,
      {
        a!pickerFieldGroups(
          label: "Group Picker",
          labelPosition: "ABOVE",
          saveInto: {
            local!assignees,
          },
          validations: if(
            contains(local!assignees, togroup(465)),
            "",
            "The  required group is missing. Please add group Writers Group Name"
          ),
          value: local!assignees
        )
      }
    )

Reply
  • 0
    Certified Senior Developer
    in reply to p2005

    As an Extension to Kumar's Solution, you can also add a validation in code like :

    This way we show an error message in case the particular group is removed.

    a!localVariables(
      local!assignees,
      {
        a!pickerFieldGroups(
          label: "Group Picker",
          labelPosition: "ABOVE",
          saveInto: {
            local!assignees,
          },
          validations: if(
            contains(local!assignees, togroup(465)),
            "",
            "The  required group is missing. Please add group Writers Group Name"
          ),
          value: local!assignees
        )
      }
    )

Children
No Data