i have used this and it doesnt display
if(${role_i_c} = ‘primary’ or ${role_i_c} = ‘alternate’, ‘national_id,not_available’, ‘birth_certificate,not_available’)
Yet when i use this it works if(${role_i_c} = ‘primary’, ‘national_id’, ‘birth_certificate’)
what could be wrong?
I need the documents to be displayed based on the roles. Eg for Principle collector the ids to be displayed should be national id and not available and for no role collectors it should be birth certificate and not available.
Someone help?
Hi @MONMAMAYAO, Welcome to the Community!
I believe it could be the because of the comma in the first if sentence, there is a comma in “national_id,not_available”, normall “,” is not not acceptable to use in the XML naming, if you switch it to “_”, your if sentence should work as expected. don’t forget to rename the question to “national_id_not_available”
if(${role_i_c} = ‘primary’ or ${role_i_c} = ‘alternate’, ‘national_id,not_available’, ‘birth_certificate,not_available’)
So it should be if(${role_i_c} = ‘primary’ or ${role_i_c} = ‘alternate’, ‘national_id_not_available’, ‘birth_certificate_not_available’)?
It should be
I will try it now and see if it works. Thank you
doesnt work
if(${role_i_c} = ‘primary’, ‘not_available_national_id’, ‘not_available_birth_certificate’)
Doesnt display anything. Not even one document
Choices are
id_type not_available
id_type national_id
id_type birth_certificate
in the form this is the way it looks
select_one id_type | id_type_i_c | true | D | E | F | G | not(selected(. | ‘not_available’) and count-selected(.) >=2) | I | J | What type of identification document is provided? | ما نوع وثيقة الهوية المقدمة؟ | M | N | O | P | Q | R | selected(${id_type_filter} | name) | T |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
calculate | id_type_filter | if(${role_i_c} = ‘primary’, ‘not_available_national_id’, ‘not_available_birth_certificate’) |
can you share your xls form with us to review in first hand?
unfortunately i cannot upload the doc as am a new user
I will tag @Kal_Lam so he can give you the permission to upload your file.
Did you check your form with the Online validator, please?
Before i am granted the rights to upload, maybe you can have some data here,
The id documents are ;
|id_type not_available 1|
|id_type national_id 2|
|id_type birth_certificate 3|
So in the form i would like to show the documents as follows;
For individual_index and alternate and collector show 1 and 2 while for number repeat show 1 and 3
The sequence of the form is such that the individual index comes first followed by the alternate collector then the number repeat
The roles as as below;
role primary 1
role alternate 2
role no_role 3
yes i did and no errors, but the form was not displaying as expected.
@MONMAMAYAO, you should already have access to upload your XLSForm to the community now! Kindly please be informed that new users generally don’t have access to this at an early stage.
It seems like you’re encountering an issue with the logic in your KoBo form. The problem likely stems from the syntax used in the conditional expression. Here are a few things to consider:
-
Syntax for Multiple Conditions: When you’re combining conditions with
or
, ensure that you’re using the correct syntax and that each condition is properly separated. Try adjusting the expression like this:if(${role_i_c} = ‘primary’ or ${role_i_c} = ‘alternate’, ‘national_id,not_available’, ‘birth_certificate,not_available’)
-
Quotation Marks: Double-check that you’re using the correct type of quotation marks. Sometimes, certain text editors or copy-pasting might change straight quotes (
'
) to curly quotes (‘’
). KoBo forms generally expect straight quotes:if(${role_i_c} = 'primary' or ${role_i_c} = 'alternate', 'national_id,not_available', 'birth_certificate,not_available')
-
Nested Logic: If your logic is more complex, consider breaking it down or using nested
if
statements to ensure clarity:if(${role_i_c} = 'primary', 'national_id,not_available', if(${role_i_c} = 'alternate', 'national_id,not_available', 'birth_certificate,not_available'))
-
Testing Individual Conditions: Since the simpler condition works, try testing the conditions individually to ensure each part works as expected before combining them.
I hope this helps you resolve the issue. Let me know if you need further assistance!
@MONMAMAYAO, please also don’t forget to validate your XLSForm through this online validator. The online validator should help you identify syntax issues within your XLSForm.