Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How can I combine conditions for validation against dataset in Confiforms?

Birte Balck July 8, 2022

Goal: I'm trying to set up a registration form for an event that takes place on two dates and for each date there are different times slots to choose from. 
There cant be more than one entry for each timeslot. 

Set-Up: I have set it up, so that first one has to choose the date (field datum).
Depending on the selection, a dropdown for either dateA (field slot1) or dateB (field slot2) are shown (resp. hidden).

The condition I want to set is a validation against dataset, so that if a slot (entry.datum + entry.slot1 OR entry.slot2) is already booked, it shows a message and the entry cant be made. 

The issue Im having: 
I can only make one entry per date (not slot). I get the same result if I leave out the date alltogether from the condition (=slot2:[entry.slot2] AND _count:>1).


Another issue, that might be related: 
If e.g. there is one entry for dateA and I'll try another one for dateA (but with another slot), I get the warning message. If I'll then make an entry for dateB, there is not only a value for slot2, but also there is a value in slot1 (which doesnt show for the user, so it should be empty, shouldn't it?).

What am I doing wrong? I am glad for any hints! Thank you!

 

<ac:structured-macro ac:macro-id="c2fe2384-7422-47ff-b3f5-df53af1602ac" ac:name="confiform-field-definition" ac:schema-version="1">
<ac:parameter ac:name="fieldName">datum</ac:parameter>
<ac:parameter ac:name="fieldLabel">Datum</ac:parameter>
<ac:parameter ac:name="values">false[1=14.09.2022|2=21.09.2022|]</ac:parameter>
<ac:parameter ac:name="extras">id;false</ac:parameter>
<ac:parameter ac:name="type">select</ac:parameter>
<ac:parameter ac:name="required">true</ac:parameter>
</ac:structured-macro>


<ac:structured-macro ac:macro-id="8ade4d24-b25a-4e83-9a4a-024fe23a2fe0" ac:name="confiform-field-definition" ac:schema-version="1">
<ac:parameter ac:name="fieldName">slot1</ac:parameter>
<ac:parameter ac:name="fieldLabel">Uhrzeit</ac:parameter>
<ac:parameter ac:name="values">false[1=8.30 Uhr|2=8.45 Uhr|3=9.00 Uhr|4=9.15 Uhr|5=9.30 Uhr|6=9.45 Uhr|7=10.00 Uhr|8=10.15 Uhr|9=10.30 Uhr|10=10.45 Uhr|11=11.00 Uhr|12=11.15 Uhr|13=11.30 Uhr|14=11.45 Uhr|15=12.45 Uhr|16=13.00 Uhr|17=13.15 Uhr|18=13.30 Uhr|19=13.45 Uhr|20=14.00 Uhr|21=14.15 Uhr|22=14.30 Uhr|23=14.45 Uhr|24=15.00 Uhr|25=15.15 Uhr|26=15.30 Uhr|27=15.45 Uhr|28=16.00 Uhr|29=16.15 Uhr|]</ac:parameter>
<ac:parameter ac:name="extras">id;false</ac:parameter>
<ac:parameter ac:name="type">select</ac:parameter>
</ac:structured-macro>


<ac:structured-macro ac:macro-id="82caea16-1e32-4569-9d4e-74b261b688db" ac:name="confiform-field-definition" ac:schema-version="1">
<ac:parameter ac:name="fieldName">slot2</ac:parameter>
<ac:parameter ac:name="fieldLabel">Uhrzeit</ac:parameter>
<ac:parameter ac:name="values">false[1=9.30 Uhr|2=9.45 Uhr|3=10.00 Uhr|4=10.15 Uhr|5=10.30 Uhr|6=10.45 Uhr|7=11.00 Uhr|8=11.15 Uhr|9=11.30 Uhr|10=11.45 Uhr|11=12.30 Uhr|12=12.45 Uhr|13=13.00 Uhr|14=13.15 Uhr|15=13.30 Uhr|16=13.45 Uhr|17=14.00 Uhr|18=14.15 Uhr|19=14.30 Uhr|20=14.45 Uhr|21=15.00 Uhr|22=15.15 Uhr|]</ac:parameter>
<ac:parameter ac:name="extras">id;false</ac:parameter>
<ac:parameter ac:name="type">select</ac:parameter>
</ac:structured-macro>


<ac:structured-macro ac:macro-id="d0945fea-a21a-43b3-8f32-0ec729c72dfe" ac:name="confiform-field-definition-rules" ac:schema-version="1">
<ac:parameter ac:name="condition">datum:1</ac:parameter>
<ac:parameter ac:name="fieldName">slot1</ac:parameter>
<ac:parameter ac:name="action">Show field</ac:parameter>
<ac:parameter ac:name="actionFieldName">datum</ac:parameter>
<ac:parameter ac:name="withReverseRule">true</ac:parameter>
</ac:structured-macro>
</p>
<p>
<ac:structured-macro ac:macro-id="9714a20b-9e95-4096-8a3a-c9fd5723f944" ac:name="confiform-field-definition-rules" ac:schema-version="1">
<ac:parameter ac:name="condition">datum:2</ac:parameter>
<ac:parameter ac:name="fieldName">slot2</ac:parameter>
<ac:parameter ac:name="action">Show field</ac:parameter>
<ac:parameter ac:name="actionFieldName">datum</ac:parameter>
<ac:parameter ac:name="withReverseRule">true</ac:parameter>
</ac:structured-macro>

<ac:structured-macro ac:macro-id="5c52613e-62d9-46cd-9acc-2bcc0be25277" ac:name="confiform-field-definition-rules" ac:schema-version="1">
<ac:parameter ac:name="condition">datum:[entry.datum] AND slot1:[entry.slot1] AND _count:&gt;1</ac:parameter>
<ac:parameter ac:name="fieldName">Der Termin ist bereits vergeben.</ac:parameter>
<ac:parameter ac:name="action">Validation rule dataset</ac:parameter>
</ac:structured-macro>


<ac:structured-macro ac:macro-id="7fbe5a5d-f772-4f15-aedc-e518f6958835" ac:name="confiform-field-definition-rules" ac:schema-version="1">
<ac:parameter ac:name="condition">datum:[entry.datum] AND slot2:[entry.slot2] AND _count:&gt;1</ac:parameter>
<ac:parameter ac:name="fieldName">Der Termin ist bereits vergeben.</ac:parameter>
<ac:parameter ac:name="action">Validation rule dataset</ac:parameter>
</ac:structured-macro>

 

 

 

 

1 answer

1 accepted

1 vote
Answer accepted
Alex Medved _ConfiForms_
Community Champion
July 8, 2022

Hi @Birte Balck  and welcome to this community

You need to understand that BOTH validation rules will kick in in your case on form submit. No matter what has been selected on the UI for the date field (datum). Easy to see when you change the "message to show on validation failure"

Therefore this needs to be taken care of in the conditions for your validation rules

datum:[entry.datum] AND slot1:[entry.slot1] AND !slot1:[empty] AND slot2:[empty] AND _count:>1

and

datum:[entry.datum] AND slot2:[entry.slot2] AND slot1:[empty] AND !slot2:[empty] AND _count:>1

as a storage format this would be as follows


<p>
<ac:structured-macro ac:macro-id="5c8987ce-dd8d-4cca-8113-82d31672e6b1" ac:name="confiform-field-definition-rules" ac:schema-version="1">
<ac:parameter ac:name="condition">datum:[entry.datum] AND slot1:[entry.slot1] AND !slot1:[empty] AND slot2:[empty] AND _count:&gt;1</ac:parameter>
<ac:parameter ac:name="fieldName">Der Termin ist bereits vergeben slot1.</ac:parameter>
<ac:parameter ac:name="action">Validation rule dataset</ac:parameter>
</ac:structured-macro>
</p>
<p>
<ac:structured-macro ac:macro-id="07cd8e26-f625-499e-b412-c2f8b270fe19" ac:name="confiform-field-definition-rules" ac:schema-version="1">
<ac:parameter ac:name="condition">datum:[entry.datum] AND slot2:[entry.slot2] AND slot1:[empty] AND !slot2:[empty] AND _count:&gt;1</ac:parameter>
<ac:parameter ac:name="fieldName">Der Termin ist bereits vergeben slot2.</ac:parameter>
<ac:parameter ac:name="action">Validation rule dataset</ac:parameter>
</ac:structured-macro>
</p>

Hope it helps

Alex

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events