Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

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

Can I condition the automation rule to update custom field only if it was previously empty? Edited

Hi, all,

 

I need to have a custom field that will reflect the first time a specific transition occurred.

First I thought I would do it with a post-change action and copy value from Updated to my custom field (Closed Initial Report).

But this does not work in cases when the issue is reopened, and will eventually go through the same transition again, so the initial value will be overwritten, which we do not want.

 

I thought I may have more options in an automation rule, and I have managed to create a rule that will populate the custom filed with the current time when the transition occurs, but I would also like to add the condition to only populate if this field was previously empty.

 

However, when I select the Issue Fields Condition and try to select my custom field (so that the action would only be performed if the field is empty) I cannot find my custom field in the picker.

 

Anyone have any ideas, or an alternative solution?

 

thank you

Dora

3 answers

I also tried to add a condition to check if issue matches JQL:

"Closed Initial Report" is Empty

 

But even in cases when "Closed Initial Report" is not empty the automation will update the field with the new value.

0 votes
John Funk Community Leader Mar 03, 2021

Hi Dora,

The best thing would be to figure out why the field is not showing up in your list. If the field was recently added, try refreshing your Automation Rules list, and then go back in to do the edit. 

Second is to make sure the field is on the Create/Edit screen and is available. 

Third, check the context for the custom field to see if it matches with the Project you are working with. 

Finally, what type of field is it? What type of project is it on? 

Hi, John,

thank you for the suggestions.

I refreshed everything several times so I'm guessing that's not the issue.

The field is not on the create screen because only the system will populate it, at a later transition, and it is not on the edit screen because users must not edit it, so I added it only to the View screen.

Just to make sure, I tried adding it to all three screens, but still it is not in the picker.

The field has a global context, but I tried to make it specific to my project, and again no luck unfortunately.

 

The strange thing is that I just noticed that the solution with JQL "Closed Initial Report" is Empty works on our Server instance, but not in Cloud.

 

In both instances the field is not available in the picker.

 

BR

Dora

John Funk Community Leader Mar 03, 2021

What type of Field? And what type of Project?

It is a Date Time Picker. Project is classic software.

John Funk Community Leader Mar 04, 2021

And you can include the field in a filter and see the results? 

And are you looking to update the field as a part of the Edit issue action?

John Funk Community Leader Mar 05, 2021

Can you include a screenshot of your rule?

 

Sure. Here it is with the JQL, because the Issue fields condition would not find my custom field.

The validation of this jql works in the server instance, but in cloud no issues match the jql.

rule.PNG

John Funk Community Leader Mar 05, 2021

Maybe try this in the More options section for JSON

{
    "fields": {
        "customfield_10003": "the value I want to set",
    }
}

I don't see the More options in any of the condition components, only in the Edit action component.

But if I add it to the action, wouldn't it have effect only on the value that will be set, and not on the condition in which it will or will not be set?

John Funk Community Leader Mar 08, 2021

Use the Advanced Compare option. There you can add in "code".

I tried this option, but none of the issues match the condition again.

 

rule2.PNG

John Funk Community Leader Mar 08, 2021

Are you sure there are issues on that project that are in the Implementation status and the custom field is empty after you updated the rule? Remember that you are firing the rule on a transition. so to test you would need to fire it with a new transition to that status. 

I definitely have some issue with this "is Empty" syntax, but not sure why.

 

There are issues in that status. On some the field is empty, and on some it is not, but the JQL says there are none where it is empty.

 

rule3.PNG

 

rule4.PNG

John Funk Community Leader Mar 08, 2021

That makes no sense whatsoever. You need to submit a support ticket with Atlassian and show them that. 

https://support.atlassian.com/contact/#/

Please post back here once you have a solution. Thanks!

Will do.

Thank you so much for your suggestions.

 

BR

Dora

John Funk Community Leader Mar 08, 2021

Sorry I couldn't have been more help, but something strange is going on there. :-)

Hi!

There is definitely a recent issue with "IS EMPTY" and text fields, and I wonder if this issue impacts other field types as well.  The apparent cause is once a field has been set and then cleared, a distinction is made between BLANK and EMPTY in JQL and the API.

You may watch the progress of the fix for this issue here:

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

The work-around I have been using for this is to check field length of zero in addition to EMPTY.  For a non-text field, you could try converting to text first and then checking length.

Best regards,

Bill

Like John Funk likes this

Thank you, Bill, I'll check out the related issues.

In my case the field is a date field, and it is never cleared, but it could be something related, as there doesn't seem to be a logical reason why the system doesn't recognize the fields as empty.

BR

Dora

Like # people like this

@Dora Lukin for a date field work-around, you could try this:

advanced compare condition for {{issue.myDateFieldName|0}} equals 0

What that will do is substitute a default of zero (0) when the field is blank or empty, and then test for zero.

__Bill

Yes, I can filter by this field without problems, and I see it on the View screen.

 

I did some testing with other custom fields and it seems none of the date pickers are available in the automation rule field picker.

 

Is this a known issue perhaps?

 

And yes, I would update the field as part of the Edit issue action.

 

thank you

Dora

Daniel Ebers Community Leader Mar 07, 2021

Yes, I experienced the same - date fields are not available in the selection.
I instead went with a JQL approach. If I understood your screenshot right the same like you did.
When needing to set such a field doing it via "More options" / JSON worked, like John said above.

As far as JSON goes, I don't actually have any issues in the edit action, as the date field is available in the action component, but unfortunately not in the condition component.

So I can edit the field, but not with a condition.

The JQL "Closed Initial Report" is Empty works for me in the server instance, but not in cloud.

For some reason in cloud the validation for "Closed Initial Report" is Empty says there are no issues that match the search, even though when the same is entered in the filter search, there are issues that match it.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS
Community showcase
Published in Marketplace Apps & Integrations

Bitbucket Smart Commits vs. Genius Commits - What's the difference?

If you already heard about Smart Commits in Bitbucket, know that you just stumbled upon something even better (and smarter!): Genius Commits by Better DevOps Automation for Jira Data Center (+ Server...

114 views 0 2
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