I'm running Confluence 7.4.0.
I want to accomplish the following: A form, where users can either pick a single date, or a date interval. Then, present the data in a calender. Should be easy, but turns out that I wasted half a day without getting anywhere.
I want date intervals to be shown as intervals in the calender, so a possible solution would be to use the field type 'Datetime interval' and, for the single date events, use the start date as the end date.
The solution I thought of has two fields of type 'Date': date0 and date1. Then I tried to use definition rules to populate a further field of type 'Datetime interval' called date2. When date1 would be empty, date0 is written in both entries of date2. If date1 holds any value, I would write date0 and date1 into date2 as start and end.
I would hide date2 in the input form, but use its values afterwards.
According to the documentation, the proper field values in date2 are date2.startDate and date2.endDate.
However, it seems to be impossible to write anything into a field of type datetime interval.
Have a look at the following definitions:
<ac:structured-macro ac:macro-id="f1b70e5e-012e-497a-ad78-9e7e0c266a6e" ac:name="confiform-field-definition" ac:schema-version="1">
<ac:parameter ac:name="fieldName">date0</ac:parameter>
<ac:parameter ac:name="fieldLabel">Von</ac:parameter>
<ac:parameter ac:name="extras">dd.MM.yyyy</ac:parameter>
<ac:parameter ac:name="type">date</ac:parameter>
<ac:parameter ac:name="required">true</ac:parameter>
</ac:structured-macro>
<ac:structured-macro ac:macro-id="c60d935d-6b11-4463-980e-e4a493f13906" ac:name="confiform-field-definition" ac:schema-version="1">
<ac:parameter ac:name="fieldName">date2</ac:parameter>
<ac:parameter ac:name="fieldLabel">Von - Bis</ac:parameter>
<ac:parameter ac:name="values">0</ac:parameter>
<ac:parameter ac:name="extras">dd.MM.yyyy</ac:parameter>
<ac:parameter ac:name="type">datetimeinterval</ac:parameter>
</ac:structured-macro>
<ac:structured-macro ac:macro-id="91bbcdfc-17d2-4f29-9d8a-bee70ec84ada" ac:name="confiform-field-definition-rules" ac:schema-version="1">
<ac:parameter ac:name="condition">!date0:[empty]</ac:parameter>
<ac:parameter ac:name="values">date2.startDate=[entry.date0]&date2.endDate=[entry.date0]</ac:parameter>
<ac:parameter ac:name="action">Set value</ac:parameter>
<ac:parameter ac:name="actionFieldName">date0</ac:parameter>
</ac:structured-macro
All the code tries to do is: If date0 changes and if it isn't empty, write its content into start and end of the datetime interval.
But it simply doesn't do anything at all.
What am I missing here? How can I properly populate the values of the datetime interval?
Note that if I replace the datetime interval with two single date fields, everything works like a charm:
<ac:structured-macro ac:macro-id="4c85eee7-62cf-4196-a77c-845a691db46b" ac:name="confiform-field-definition" ac:schema-version="1">
<ac:parameter ac:name="fieldName">a</ac:parameter>
<ac:parameter ac:name="fieldLabel">b</ac:parameter>
<ac:parameter ac:name="extras">dd.MM.yyyy</ac:parameter>
<ac:parameter ac:name="type">date</ac:parameter>
</ac:structured-macro>
<ac:structured-macro ac:macro-id="aa120788-f70d-45e6-aeb5-482ab0dccca8" ac:name="confiform-field-definition" ac:schema-version="1">
<ac:parameter ac:name="fieldName">c</ac:parameter>
<ac:parameter ac:name="fieldLabel">d</ac:parameter>
<ac:parameter ac:name="extras">dd.MM.yyyy</ac:parameter>
<ac:parameter ac:name="type">date</ac:parameter>
</ac:structured-macro>
<ac:structured-macro ac:macro-id="c049704f-a8e3-404e-b1bc-4519319eb5bc" ac:name="confiform-field-definition-rules" ac:schema-version="1">
<ac:parameter ac:name="condition">!date0:[empty]</ac:parameter>
<ac:parameter ac:name="values">a=[entry.date0]&c=[entry.date0]</ac:parameter>
<ac:parameter ac:name="action">Set value</ac:parameter>
<ac:parameter ac:name="actionFieldName">date0</ac:parameter>
</ac:structured-macro>
This has to do with datetime interval, but I cannot figure out what.