Validating Cases in a lookup table

Hi I have a multi select lookup table fetching data as below
instance(‘casedb’)/casedb/case[@case_type = ‘hh_members’][selected(service_mapping, ‘pmg’)][@status = ‘open’]

It’s purpose is to attach members to groups called ‘Producer Marketing Groups’.

What I want to fix is if a person A has already been added to a group, his name should be inactive or not displayed or rather return a message that this person already belongs to a group when I am creating a new group with new members

How are you attaching members to the groups? Are those groups cases and they store the case_id of the hh_member? Or are you just storing the group name on the hh_member case? Depending on your answer to that the xpath would be different, but in general you’ll want to use a count() expression to check if the hh_member is on more than one group. And either put that count() in the validation condition to warn that the person has already been selected, or you can put it as another clause in the xpath you wrote above.

Hi Nick, Thanks for the reponse. I will only be saving group names to hh_member case

Great.

To filter hh_members that already have a group selected you can add the
following to your expression (I’m assuming the case property you are saving
to is hh_member_group_name):

instance(‘casedb’)/casedb/case[@case_type =
‘hh_members’][selected(service_mapping,
‘pmg’)][@status = ‘open’][hh_member_group_name != ‘’]

If you want, instead for it to just return a warning message you need to:

  1. save @case_id as the “Value Field” in the select list and 2) put the
    following in the validation condition on the question:

count( instance(‘casedb’)/casedb/case[@case_id = .][hh_member_group_name
!= ‘’]) > 0

The @case_id = . sets the filter for the case that was just selected. And
the hh_member_group_name != ‘’ checks that the selected case doesn’t
already have a group specified

2 Likes