Automation that reviews if multiple fields are empty and adds comment indicating specific fields
Asked by Tyler Flores:

I want to write a JPD automation that checks if multiple fields are empty; and then adds a comment indicating such.

Example:

* Field 1: Dummy data
* Field 2: "Empty"
* Field 3: "Empty"
* Field 4: Dummy data

In this instance, the comment should indicate that Fields 2 \& 3 are empty and need to be populated. I know I can add automations for each field and have separate comments for each one but wanted to see if it was possible to consolidate into a single comment.


Answers:
author: Bill Sheboy
body: Hi [@Tyler Flores](/t5/user/viewprofilepage/user-id/5523470) -- Welcome to the Atlassian Community!

Yes, that is possible, although there is no single "walk over all fields to look for empty" technique that I am aware of.

You could do this inline as the comment is created, testing each field of interest. Or, use conditions and created variables to build-up what you want to post in the comment later in the rule.

As with many things automation-related, the details are important. Different field types require different techniques to detect "empty", so experimentation may be required.

Kind regards,  
Bill

comments: author: Tyler Flores
body: These fields are custom basic single-select dropdown so I don't think the detection part is too difficult.

What I don't know how to do is "You could do this inline as the comment is created, testing each field of interest. Or, use conditions and created variables to build-up what you want to post in the comment later in the rule."

What is the syntax to do this within the Action of Adding a Comment? Or would creating the variable be a better solution?


author: Aaron Pavez _ServiceRocket_
body: Hi [@Tyler Flores](/t5/user/viewprofilepage/user-id/5523470)

The automation with the comment is doable.

When : For example lets use manual trigger for now

IF -Issue fields condition: custom field is empty

Then: add comment issue

use: smart value {{issue.fields.customfield_xxxxx.name}} -\> but this one doesn't work at all in Jira cloud.

I was trying to do this, but it seems none of these works to get the custom field name:

* {{issue.fields.customfield_xxxxx}}
* {{issue.fields.customfield_xxxxx.name}}
* {{issue.fields.my custom field}}
* {{issue.fields.my custom field.name}}

[@Bill Sheboy](/t5/user/viewprofilepage/user-id/1685313) Do you know how can get the name of the field?

Regards

comments: author: Bill Sheboy
body: Hi [@Aaron Pavez _ServiceRocket_](/t5/user/viewprofilepage/user-id/4482404)

I recall seeing another post about getting custom field names in rules, and my experiments showed:

The {{issue.customfield_12345.name}} does not return the name for Jira Cloud, even though the docs indicate it does: <https://support.atlassian.com/cloud-automation/docs/jira-smart-values-issues>.

I was able to get the name using a Send Web Request action calling the REST API with the expand=names parameter and then parsing the value from the *names* attribute: <https://support.atlassian.com/cloud-automation/docs/find-the-smart-value-for-a-field/>

Kind regards,  
Bill


author: Aaron Pavez _ServiceRocket_
body: Hi!

Yeah, I came to the same conclusion. Only the API call will get me the name.

Thanks for the confirmation!

Regards


author: Tyler Flores
body: Hi Aaron, from what you're proposing - it sounds like it would add a new comment for each empty field correct? Is there a way to consolidate?


Tags: automation

cloud

comment

condition

jira-cloud

jira-product-discovery

jpd