Forums

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

Conditionally set start date of issue when starting progress

Zoltán Lehóczky
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.
October 8, 2018

I'd like to update the "Start date" field of an issue to to the current date when somebody starts progress on it, but only if such an update wasn't done already (in the case the issue goes from in progress to done, then from in review back to to do). How would you do this with JMWE?

The field always has a value, since it's filled when doing the planning for a project with BigGantt's gantt chart. I'd like it to get automatically updated in case the issue is started before or after the originally planned date.

I thought of adding another boolean field (maybe a single choice select list) to the issue along the lines of "Start date was updated". The field wouldn't be actually displayed to users on any screens and would be false by default. Then in a JMWE Post Function I'd write some conditional Nunjuck script to update the date only if this field's value is false (and then also set "Start date was updated" to true).

Is there any easier way to do a conditional update like this? Do you see any issues with what I outlined?

Thank you in advance!

1 answer

1 accepted

0 votes
Answer accepted
David Fischer
Community Champion
October 9, 2018

Hi Zoltán,

since you really cannot know where the current value of the "Start date" field comes from (BigGantt or the JMWE post-function), your idea of "memorizing" that you've been through the Start Progress transition before is the right one.

You can do this with a hidden custom field, that you set (using the Set Field Value post-function) on the Start Progress transition, with a small delay to make sure it runs after the other Set field Value post-function that sets the Start date field. Then you can test the value of that field in the conditional execution "script" of the latter.

You can also achieve the same using an "issue entity property" instead of a custom field. You can set the Issue Entity Property using the "Set entity property value" post-function (again with delayed execution), and test it in the conditional execution template using the issueProperty Nunjucks filter. The result will be the same but you won't clutter your custom fields page needlessly. 

Zoltán Lehóczky
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.
October 9, 2018

Thanks for the answer David, sounds perfect. I didn't know about entity properties, nor thought about having a delay, so important points.

I wondered why there is a second function needed to set the issue property, but it seems there's no way to set, just get the value of an issue property in Nunjuck, so I understand now.

I ended up doing this:

  1. "Set field value" Function: setting the Start date field. Value:
    {{ now | date('tz') | date("YYYY-MM-DD") }}
    I used a condition for the Function:
    {{ issue | issueProperty("StartDateWasSet") != "true" }}
  2. "Set Entity Property value" Function: setting the StartDateWasSet property with a delay of 20s. Using such delays seems to be a bit fragile to me (what happens if there's some hiccup in the system and the previous function takes more), but this should be enough and even if the update fails it's not a huge issue.
David Fischer
Community Champion
October 9, 2018

You don't need such a big delay - a couple of seconds is enough.

I agree delays are flaky, but unfortunately Jira Cloud triggers post-functions asynchronously so there's no good way to force any execution order.

Suggest an answer

Log in or Sign up to answer