Condition does not work when the language is set to EN (US)
Asked by Martin:

Hello all,

I have created two forms. In the first form you can create appointments, which are then available for selection in the other form.  
The appointments have the elements location, date and time. The date has the format "dd.MM.yyyy". To prevent multiple appointments from being selected in the same week, the date is converted to the format "yyyy, w". Now the macro "ConfiForms Form Field Definition" and the type "Validation rule (dataset)". Now I check if there is already an entry from the user in the calendar week. This works as long as the language in Confluence is not set to EN (US) but to e.g. German or EN (GB). Probably the reason is that the format of the date is different in EN (US). But this format is predefined in the macro. Another peculiarity is that the value of the calendar week changes in the data set when you change from German to EN (US) and vice versa.

Below is the code. Maybe someone can help me.

Create dates:

```
<p class="auto-cursor-target">
<br/>
</p>
<ac:structured-macro ac:macro-id="12b9fddb-ea0d-4fa3-8f4d-2130a039f162" ac:name="confiform" ac:schema-version="1">
<ac:parameter ac:name="formName">testForm</ac:parameter>
<ac:rich-text-body>
<p>
<ac:structured-macro ac:macro-id="9c71ce5c-c97d-4a98-b02a-1df123b2ba1f" ac:name="confiform-field-definition" ac:schema-version="1">
<ac:parameter ac:name="fieldName">location</ac:parameter>
<ac:parameter ac:name="fieldLabel">location</ac:parameter>
<ac:parameter ac:name="values">false[Berlin=Berlin|Madrid=Madrid|]</ac:parameter>
<ac:parameter ac:name="type">select</ac:parameter>
</ac:structured-macro>
</p>
<p>
<ac:structured-macro ac:macro-id="b8907bfa-42e4-415e-9909-26227f658cf8" ac:name="confiform-field-definition" ac:schema-version="1">
<ac:parameter ac:name="fieldName">date</ac:parameter>
<ac:parameter ac:name="fieldLabel">date</ac:parameter>
<ac:parameter ac:name="extras">dd.MM.yyyy</ac:parameter>
<ac:parameter ac:name="extracontext">false</ac:parameter>
<ac:parameter ac:name="type">date</ac:parameter>
</ac:structured-macro>
</p>
<p>
<ac:structured-macro ac:macro-id="7f1c2a76-a4ed-4d0f-89ef-637af53294b9" ac:name="confiform-field-definition" ac:schema-version="1">
<ac:parameter ac:name="fieldName">time</ac:parameter>
<ac:parameter ac:name="fieldLabel">time</ac:parameter>
<ac:parameter ac:name="type">time</ac:parameter>
</ac:structured-macro>
</p>
<ac:structured-macro ac:macro-id="3a3ee08c-5828-4cab-bf7d-ad85b087840f" ac:name="confiform-entry-register" ac:schema-version="1">
<ac:parameter ac:name="type">Embedded</ac:parameter>
<ac:parameter ac:name="atlassian-macro-output-type">INLINE</ac:parameter>
<ac:rich-text-body>
<p>
<br/>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<p class="auto-cursor-target">
<br/>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<p class="auto-cursor-target">
<br/>
</p>
```

Book dates:  

```
<p class="auto-cursor-target">
<br/>
</p>
<ac:structured-macro ac:macro-id="e582eb6b-fe8a-4e68-adfa-972fe2d03815" ac:name="confiform" ac:schema-version="1">
<ac:parameter ac:name="formName">testForm</ac:parameter>
<ac:rich-text-body>
<p>
<ac:structured-macro ac:macro-id="ee236e5b-1d91-4244-8df6-251d9d4b4806" ac:name="confiform-field-definition" ac:schema-version="1">
<ac:parameter ac:name="fieldName">user</ac:parameter>
<ac:parameter ac:name="fieldLabel">user</ac:parameter>
<ac:parameter ac:name="values">false[]</ac:parameter>
<ac:parameter ac:name="type">user</ac:parameter>
</ac:structured-macro>?<ac:structured-macro ac:macro-id="23bc9dd2-5711-4e68-9fff-54501387a7b4" ac:name="confiform-field-definition" ac:schema-version="1">
<ac:parameter ac:name="fieldName">calendarWeek</ac:parameter>
<ac:parameter ac:name="fieldLabel">calendarWeek</ac:parameter>
<ac:parameter ac:name="extras">YYYY-ww</ac:parameter>
<ac:parameter ac:name="extracontext">false</ac:parameter>
<ac:parameter ac:name="type">date</ac:parameter>
</ac:structured-macro>
<ac:structured-macro ac:macro-id="543561dc-0092-49f4-a10f-9574d0ed5f17" ac:name="confiform-field-definition" ac:schema-version="1">
<ac:parameter ac:name="fieldName">multi</ac:parameter>
<ac:parameter ac:name="fieldLabel">multi</ac:parameter>
<ac:parameter ac:name="values">[209421409:testForm]location,date,time,</ac:parameter>
<ac:parameter ac:name="type">smartclass</ac:parameter>
</ac:structured-macro>
</p>
<p>
<br/>
</p>
<p>
<ac:structured-macro ac:macro-id="a893de5d-8c97-49a3-953b-f5916208e101" ac:name="confiform-field-definition-rules" ac:schema-version="1">
<ac:parameter ac:name="condition">user:[entry.user] AND calendarWeek:[entry.calendarWeek] AND !id:[entry.id]</ac:parameter>
<ac:parameter ac:name="fieldName">You have already made an appointment!</ac:parameter>
<ac:parameter ac:name="action">Validation rule dataset</ac:parameter>
<ac:parameter ac:name="actionFieldName">multi</ac:parameter>
</ac:structured-macro>
</p>
<p>
<ac:structured-macro ac:macro-id="74d4ecff-cb21-49d0-a746-3b90a3fd4f01" ac:name="confiform-field-definition-rules" ac:schema-version="1">
<ac:parameter ac:name="fieldName">Hast dich schon registriert dude!</ac:parameter>
<ac:parameter ac:name="values">datum=[entry.multi.date]</ac:parameter>
<ac:parameter ac:name="action">Set value</ac:parameter>
<ac:parameter ac:name="actionFieldName">multi</ac:parameter>
</ac:structured-macro>
</p>
<p>
<br/>
</p>
<p>
<ac:structured-macro ac:macro-id="7716f52d-52fa-49bc-a925-9204c3e26288" ac:name="confiform-field-definition-rules" ac:schema-version="1">
<ac:parameter ac:name="values">calendarWeek=[entry.multi.date]</ac:parameter>
<ac:parameter ac:name="action">Set value</ac:parameter>
<ac:parameter ac:name="actionFieldName">multi</ac:parameter>
</ac:structured-macro>
</p>
<p>
<br/>
</p>
<p>
<br/>
</p>
<ac:structured-macro ac:macro-id="deffeb71-301e-4ec5-9620-dff2bf2a4ff0" ac:name="confiform-entry-register" ac:schema-version="1">
<ac:parameter ac:name="presetValues">user = [entry._user.fullName]</ac:parameter>
<ac:parameter ac:name="type">Embedded</ac:parameter>
<ac:parameter ac:name="atlassian-macro-output-type">INLINE</ac:parameter>
<ac:rich-text-body>
<p>
<ac:structured-macro ac:macro-id="d7f853ba-710b-4ebd-8090-b4e6ef49a388" ac:name="confiform-field" ac:schema-version="1">
<ac:parameter ac:name="fieldName">user</ac:parameter>
</ac:structured-macro>??</p>
<p>
<ac:structured-macro ac:macro-id="4a66b48b-7fc9-4b8c-bb6f-5b167dc00c7b" ac:name="confiform-field" ac:schema-version="1">
<ac:parameter ac:name="fieldName">multi</ac:parameter>
</ac:structured-macro>
</p>
<p>
<br/>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<p class="auto-cursor-target">
<br/>
</p>
<p class="auto-cursor-target">
<br/>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<p class="auto-cursor-target">
<br/>
</p>
<ac:structured-macro ac:macro-id="500ef015-fd6a-48e7-babf-ea180c20668b" ac:name="confiform-table" ac:schema-version="1">
<ac:parameter ac:name="formName">testForm</ac:parameter>
<ac:rich-text-body>
<p>
<br/>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<p class="auto-cursor-target">
<br/>
</p>
```


Answers:
author: Alex Medved _ConfiForms_
body: You are using

```
YYYY-ww
```

Are you sure you want to use "Week year", instead of "year" in your formatting pattern?

<https://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html>

I would also change the validation condition to be something like

```
user:[entry.user] AND calendarWeek.formatDate(yyyyww):[entry.calendarWeek.formatDate(yyyyww)] AND !id:[entry.id]
```

Alex

comments: author: Martin
body: Thanks Alex!

I removed the date format from calendarWeek and used your condition and it works no matter what language Confluence is set to.

Thanks a lot!

I had also tested it before with "yyyy , w" and it didn't work either. I don't understand why it works with formatDate() but not with the default formatting in the macro.

And if I keep the format "yyyy, w" in the macro and change the language in Confluence, the value changes from eg.  
EN (US): 21.04.2021: 2021, 16 to DE: 21.04.2021: 2021, 14

Which means I could book two dates in the same week if I keep the format in the macro and change the language.

But without, it works like i want to.


author: Alex Medved _ConfiForms_
body: The important thing here is to compare dates in some "common format" and this is what I do in my condition (transforming both values to some common format for comparison)


Tags: confiforms

confluence-server

server