Forums

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

Set custom field date picker default value now+Hours

Hadas Hamerovv
Contributor
November 7, 2021

Hi All,

I've created a date picker custom field.

I wish to give it a default value of {{Now}}+X Hours

Is there a simple wat to do that?

2 answers

0 votes
Hadas Hamerovv
Contributor
November 24, 2021


Very simple.

I have a transition screen with a date picker field / I am able to set its default value to { now } but am not able to set it to few hours ahead of the current time.

Now for the motivation:

We allow users to assign an issue temporarily to someone else. Setting the field to a future time will reassign back to current user automatically
They asked for a default value of 12h from current time so they don’t have to manually enter this. If this interval suites them than it’s set. If they want another time they ya of course modify the field’s value. 

0 votes
Jack Brickey
Community Champion
November 7, 2021

You could do this with automation but what would be your trigger?

Hadas Hamerovv
Contributor
November 9, 2021

Good question. I do not have an answer for that yet. 
let me tell you more about the scenario. I’ve created a looped transition for asking for more information. For the transition I’ve created a screen where the user can set the assignee, the question and the time by which he needs the answer. 
I than created an scheduled rule which checks whether there was answer given and if not it assigns the issue back to the one who asked the question. (And also sends a message to both users)

now, our rnd manager asked that the default time for waiting would be 24 hours. This is why I wanted the date picker to have a dynamic default value. 

maybe I am tackling the whole questioning idea wrong so I am more than ready to hear other suggestions 

Hadas Hamerovv
Contributor
November 21, 2021

I need the trigger to be something between when the user presses the transition button and before he execute the transition itself. Therefor I do not know if it is possible.

Any Idea?

Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 22, 2021

Hi @Hadas Hamerovv 

I am still a bit puzzled by what problem you are trying to solve.

Anyway...you may want to consider using the field value changed trigger, checking for a change to your custom field.  That may work more reliably as that transition may fire prior to the field change...leaving the data not yet set.

Kind regards,
Bill

Hadas Hamerovv
Contributor
December 3, 2021

Hi Bill,

Sorry for the long delay in returning here.

Here is the thing:

I have created a looped transition that allows users to ask one each other questions and get answers. (The main benefit is that the issue status and assignee is changed when asking so the one who asks does not see the issue on him anymore and when answering the issue automatically returns to the old status and assigned back to the person who asked the question.)

This works like charm.

In addition we have a time field where the person asking can set a timeout for waiting. If the timeout is reached without the other person replying than they both get messages and the issue returns to the person who asked and the status it was in.

Now - They asked me to set this timeout field default value to now + 12 hours.

This means that if the person asking does not change this field, the timeout is set to 12 hours. 

He of course may change it to anything else or delete the value so there is no timeout. (in this case the issue stays at the receiver until answered.)

This is the need.

I could set the default value to now however I could not set it to now+12 hours.

Hope now it is clearer

Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 3, 2021

Hi @Hadas Hamerovv 

One approach to do this is not to set a default value.  Instead use a transition-trigged rule which checks if the timeout field is empty, and then set it to {{now.plusHours(12)}} as shown here: https://support.atlassian.com/cloud-automation/docs/jira-smart-values-date-and-time/#Example.6

If instead the person asking set the timeout value, that is used rather than the incremented value.

Kind regards,
Bill

Hadas Hamerovv
Contributor
December 3, 2021

If the field is empty it means the user does not want to set a timeout but wait as long as is takes for the answer to be given.

I therefore set a default value of now to the field and set the following automation rule:

condition:

issueInput.fields.customfield_10048 != null && issueInput.fields.customfield_10048 < {{now.plusHours(0.5)}}

than

issueInput.fields.customfield_10048 = {{now.plusHours(12)}}

 

Similar to what you suggest.

I hope it will work.

Hadas Hamerovv
Contributor
December 3, 2021

Checking this I find the field empty and now see there is a bug registered in Jira log for this. What to do?

How can I set a default value for this field?

Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 3, 2021

What is the error you are seeing in the audit log?  Would you please post an image of the log showing the error and your complete rule?  Thanks!

 

One challenge with your solution approach is that you are trying to represent three conditions/pieces of information with one custom field:

  • custom field is empty: no timeout to answer the question
  • custom field is not empty: there is a timeout, and...
    • the value is less than 0.5 hours absolute difference from now, so add 12 hours
    • otherwise use the timeout as entered

Given automation rules might not fire when expected (due to rule errors, performance, and outages) that may lead to unpredictable behavior.

 

Another solution approach would be to use a single-select dropdown field of possible response times: No hurry, 1 hour, 4 hours... and then when the field changes, compute the timeout field by incrementing {{now}} or clearing the timeout for "No hurry".

Hadas Hamerovv
Contributor
December 3, 2021

Not yet tired the rule so there are  no errors.

What I see is that the default value of the field is not populated. The field is empty.

And I see a bug mentioned here:

https://jira.atlassian.com/browse/JRACLOUD-68019

Suggest an answer

Log in or Sign up to answer