How to trigger automation action only when the date field is changed for the second attempt

Vicky S April 2, 2024

I have a custom date field , I need to use automation which will add a label once any of the user changes the date manually but only for the second time so as to then add the label as Re-Planned , but for all my tries the label is getting added even for the first time when someone selects a date from empty state .(want the label to be added only when it has a value before) Can you please guide me the automation rule here may be using smart values ?  Thanks!  @Bill Sheboy 
Just Fyi I have also tried else condition but that doesnt make any difference either.

Rule.jpgAudit.jpg

2 answers

1 accepted

3 votes
Answer accepted
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.
April 2, 2024

Hi @Vicky S 

I believe this needs a couple of conditions...assuming the trigger is specifically on your date field changing.

  • First check if the label exists.  If it does not, proceed with your next condition...
  • For the first time check if {{fieldChange.fromString}} does not equal empty
  • Then set the label.

Kind regards,
Bill

Vicky S April 2, 2024

Hi @Bill Sheboy  !

- At the point where I had to select edit issue fields action - labels It allowed me to create a new label and add.

- Regarding {{fieldChange.fromString}}  i did try that aswell . attaching the audit logs and rule. It passes saying did match condition :(  - So i create a issue , then edit it to have a date , then change that date . audit02.jpg

Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 2, 2024

Can you use the Log Action to print the {{fieldChange}} smart values for fromString and toString into the log before the Condition step?

Like Bill Sheboy likes this
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.
April 2, 2024

First thing: the trigger is the generic one for Issue Updated.  I recommend changing that to issue Field Value Changed.  That will help focus your testing as the rule you show could be triggering on other issue changes.

 

Next, let's map out the cases so you can exercise them.  Please adjust accordingly.

  1. GIVEN date is empty WHEN date set to a value THEN label not added
  2. GIVEN date has a value AND label not present WHEN date set to new value THEN label added
  3. GIVEN date has a value AND label present WHEN date set to new value THEN label is not added again
  4. GIVEN date has a value WHEN date value is cleared THEN ???

 

Next after the trigger, write to the log with the values of {{fieldChange.fromString}} and {{fieldChange.toString}}.  Those will help confirm the values the rule can see before making further changes.

Like # people like this
Vicky S April 3, 2024

AddAudit.jpg

Hi attaching the audit value results , 
Regarding your points. Just to let you know I m the jira admin for our jira instance , where we have this requirement from a internal user. 

3. GIVEN date has a value AND label present WHEN date set to new value THEN label is not added again.  - Here we need that a new label should be added and that must have changed date in the label string so that to know it was changed. ( so a date can be re-planned multiple times) eg : re-planned 4/Apr/24




Vicky S April 3, 2024

NewAuto.jpg

I tried adding the if condition as above now , and got success finally to start with second attempt change it is now adding the label :)

Now we have a task to modify labels to also include the changed dates , also on further iterations .. like 3rd or 4th change then also include the date from log and create a label with that from and to : date

Like Bill Sheboy likes this
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.
April 3, 2024

Progress!

Now you want to add / remove labels, having the label somehow reflect the date change.  Is that correct?

If so, what is the format you expect in the label?

Vicky S April 3, 2024

Yes, Ideally what is required is this - "Story summary\Feature Name + date change"  this operation should occur without replacing the current labels in the issue .

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.
April 4, 2024

Is the feature the parent of the Story (i.e., an Epic issue type), or a custom field in the story?

That will be a long label as it includes the Story's Summary and Epic Summary / Name.  And it could fail to add if there are special characters in the Summary.  The spaces need to be replaced with another character, such as an underscore, using text functions and the date will need formatting.

Assuming it only has alphanumeric characters and spaces, it could be this expression, using an example date field:

{{issue.summary.replace(" ","_").concat("/").concat(issue.parent.summary.replace(" ","_")).concat(":_").concat(issue.myDateField.jiraDate)}}

Producing a label value like this:

My_story_summary_text/My_epic_summary_text:_2024-04-04

Please adjust using the text functions and date formats to match your exact needs:

 

I recommend writing the expression to the audit log before trying to add the label.  This will help to identify any errors preventing label adds.

 

Vicky S April 4, 2024

Thanks @Bill Sheboy , audit log gives me correct value out of 

{{issue.summary.replace(" ","_").concat("/").concat(issue.parent.summary.replace(" ","_")).concat(":_").concat(issue.myDateField.jiraDate)}}

Now how can I put this into the label :) 
I tried few things like creating variable then adding it , but may be I m doing it wrong .Kindly guide . Also I really appreciate the upto mark solutions you are proving until now ! thks 
Newaudit.jpg

Also about the feature linking its more like a field and not parent-child , that is only for tasks and subtasks in our Jira instance .

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.
April 4, 2024

Looking at that image, there appear to be extra curly brackets around the expression when you create the variable.  Please remove those and re-test.

Like Vicky S likes this
Vicky S April 17, 2024

Hi @Bill Sheboy , sorry I have been away for few days, but thanks for your replies and yes after making the changes as you suggested it works like a charm! .Thank you for your support in this and I look forward to learn more from your answers in future :)
Thanks @Trudy Claspill  aswell.

Like Bill Sheboy likes this
1 vote
Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 2, 2024

Hello @Vicky S 

Your post is tagged as hosting=Cloud, but the images you shared show the graphics that are used in Jira self-hosted. Can you click on the ? button near your avatar and select About Jira and tell us what it says for version?

The rule you have now basically says if the field has been change and the change did not clear the field, then add the label.

 

Previous value  New value  Add Label? 
blank  some date 
some date  blank 
some date  some other date  Y

 

If it should only add the label in the last case, then you need to check what the value was before the change.

After triggering the rule you need to add a Condition to check the previous value of the field.

With the Field Value Change trigger you have access to a special smart value that gives you details about the change. That smart value is {{fieldChange}} and is mentioned in the description of the trigger here.

https://confluence.atlassian.com/automation/jira-automation-triggers-993924804.html

If you follow the link for that smart value it takes you to another document.

https://confluence.atlassian.com/automation/jira-smart-values-issues-993924860.html#Jirasmartvaluesissues-fieldchange

There you can learn about the attributes of the {{fieldChange}} smart value. You can set up a condition to look at {{fieldChange.fromString}}, which is the value of the field before it was changed.

Note that could ensure there was a date in the field before, making this change at least the second time the field was set to a date. However, it would also pass if it was the third or fourth (and son on) time the field changed from one date to another. Do you need to add the label in those cases also?

Vicky S April 2, 2024

Hi , yes i m using a Jira Data center version , unfortunately I tried to search for the data center tagged post but could not find one , it showed only cloud products.

Although i did try using smart values as attached image but failed to get a value of the field . 

I think when the date is changed for more than 2nd time I would not need the label added .  Thanks 
smartvalueTry.jpg

Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 2, 2024

It looks like @Bill Sheboy has already provided guidance on the condition you need to use. Bill is more knowledgeable about Automation than I am, so you should proceed with his guidance. If I think I have anything useful to add, I'll chime in on his answer thread.

Like Vicky S likes this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS
AUG Leaders

Atlassian Community Events