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.
Hi @Vicky S
I believe this needs a couple of conditions...assuming the trigger is specifically on your date field changing.
Kind regards,
Bill
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 .
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Can you use the Log Action to print the {{fieldChange}} smart values for fromString and toString into the log before the Condition step?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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 .
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
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 .
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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 | Y |
some date | blank | N |
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.
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.