Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

ConfiForm: How to populate a date interval using definition rules

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]&amp;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]&amp;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.

1 answer

1 accepted

The format expected by the date time interval field is the interval given as 2 timestamps separated by -

date2=[entry.date0]-[entry.date0]

However this does not make much sense as you will have a "zero" length interval where the start date is the same as end date

Thank you, now it works perfectly.

Regarding the zero length interval: this denotes a single day. It doesn't look like the interpreter really subtracts two number here, but rather creates a string and parses it into an interval type.

This should be part of the documentation, imho.

Is this how you would map a datetime interval field to a Jira date field? I have a ConfiForm that has a datetime interval time field and Jira does not have a similar field type. Would you just map the confiform field to a two different JIRA date picker fields like this:

Period Start - "customfield_1111": "[entry.dateinterval.startDate.escapeJSON]",

Period End - "customfield_2222": "[entry.dateinterval.endDate.escapeJSON]",

Dates in Jira REST API are expected to be in yyyy-MM-dd format

So, it will be something like:

[entry.dateinterval.startDate.jiraDate]

 or

[entry.dateinterval.startDate.formatDate(yyyy-MM-dd)]

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Confluence

🥓🙅🏻‍♀️ Meet-less May Badge!

Hello Confluence Community!  What if i told you that you could have a healthier life and be 100% meet-less? This month, we're promoting a healthy, balanced work diet with Confluence. We la...

195 views 2 13
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you