Multiple choice - deselect


(Bukenya Ivan) #1

Hi All,
I have a Challenge whereby I want a Mobile Worker to select from the Multiple Choice Question which says: What is the Position of the Member in the Group; Options - Chairperson, Vice-Chairperson, Secretary, Others (Specify). From this Question, this implies that there can only be one Chairperson, Vice-Chairperson, and Secretary, then Others Positions will fall in “Others (Specify)”. So, what I need to see is that When one of these Positions is selected, then it cannot be selected again thereby avoiding data errors of having cases of two Chairpersons or Vice-chairpersons or Secretaries in one Group. Thank you.


(Clayton Sims) #2

Hi,

Is all of this happening in one form, or are the roles you are referring to being attached to Case Data that needs to influence the entry of a different form in the future?

-Clayton


(Bukenya Ivan) #3

Its Happening within one Form since its a repeat Group registering committee Members and that is why we have to capture only one Chairperson etc. Thank you


(Clayton Sims) #4

Hi,

You can use the count() function along with a Filter expression to create a display condition which will allow you to show the user an error that they cannot bypass if they select the same role for more than one person.

If you copy the chunk of text below and paste it into the form builder it should provide an example that demonstrates this behavior:

Form Builder clip	version 1
id	type	labelItext:en-default	constraintMsgItext:en-default	appearance	calculateAttr	comment	constraintAttr	rawDataAttributes	relevantAttr
/wrapper_repeat_uniqueness	Group	null	null	null	null	null	null	null	null
/wrapper_repeat_uniqueness/repeater	Repeat	null	null	null	null	null	null	"{""jr:template"":""""}"	null
/wrapper_repeat_uniqueness/repeater/name	Text	Name:	null	null	null	null	null	null	null
/wrapper_repeat_uniqueness/repeater/role	Select	Role	null	null	null	null	null	null	null
/wrapper_repeat_uniqueness/repeater/role/leader	Choice	Leader	null	null	null	null	null	null	null
/wrapper_repeat_uniqueness/repeater/role/supporter	Choice	Supporter	null	null	null	null	null	null	null
/wrapper_repeat_uniqueness/leader_check	Trigger	"You can only have one ""Leader"", but the following people are all chosen as leaders: <output value=""#form/wrapper_repeat_uniqueness/optional_list_of_leaders"" /> "	Please go back and ensure that only one person has been chosen as the leader	minimal	null	null	false()	null	#invalid/xpath count(`#form/wrapper_repeat_uniqueness/repeater`[role = 'leader']) > 1
/wrapper_repeat_uniqueness/optional_list_of_leaders	DataBindOnly	null	null	null	"join("", "", /data/wrapper_repeat_uniqueness/repeater[role = 'leader']/name)"	This is optional, and can be removed if overly complex	null	null	null

(Bukenya Ivan) #5

Hi Clayton_Sims,
Am just a beginner as regards to CommCare HQ, so kindly how and where to Past the code provided, because I tried running under the form’s XML Source editor but I get Errors.
Thank you.