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

Dora Lukin March 3, 2021

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

1 accepted

0 votes
Answer accepted
John Funk
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 3, 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? 

Dora Lukin March 3, 2021

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
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 3, 2021

What type of Field? And what type of Project?

Dora Lukin March 4, 2021

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

John Funk
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 4, 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
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 5, 2021

Can you include a screenshot of your rule?

Dora Lukin March 5, 2021

 

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
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 5, 2021

Maybe try this in the More options section for JSON

{
    "fields": {
        "customfield_10003": "the value I want to set",
    }
}
Dora Lukin March 7, 2021

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
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 8, 2021

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

Dora Lukin March 8, 2021

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

 

rule2.PNG

John Funk
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 8, 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. 

Dora Lukin March 8, 2021

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
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 8, 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!

Dora Lukin March 8, 2021

Will do.

Thank you so much for your suggestions.

 

BR

Dora

John Funk
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 8, 2021

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

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.
March 8, 2021

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
Dora Lukin March 9, 2021

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
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.
March 9, 2021

@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

Like John Funk likes this
Sayan Kaiser December 19, 2021

Thanks @Bill Sheboy this has worked for me 

Like # people like this
0 votes
Dora Lukin March 5, 2021

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
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.
March 7, 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.

Dora Lukin March 8, 2021

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.

0 votes
Dora Lukin March 3, 2021

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.

Suggest an answer

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

Atlassian Community Events