Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Can I building condition in A4J that check if certain field is exist in issue screen or not?

Eliyahu Klein --CNTR February 11, 2025

Hi,

I want to build a global automation rule that uses an 'If/Else condition' component to fill a specific field only if the field exists on the issue screen. Else - If the field does not exist, the rule should not attempt to fill it.

Currently, I am encountering an error message: 'The set fields may be unavailable for this project/type'

How can I build this rule correctly?

Screenshot 2025-02-11 174827.png

2 answers

0 votes
John Funk
Community Champion
February 11, 2025

Hi Eliyahu,

You should add a context to the custom fields so that they only apply to the appropriate projects and/or issue types first. That will enhance performance for your system and will take care of the need to try to handle with the automation rule. 

Eliyahu Klein --CNTR February 11, 2025

Hi @John Funk ,

Thank you for your response. I checked the context for the custom fields, and it seems to be set correctly. However, I am still encountering the error message in the automation rule: "The set fields may be unavailable for this project/type."...

John Funk
Community Champion
February 14, 2025

You still need to add the field(s) to the Edit screen (and/or Create screen). They just won't run for the issue types/projects that are not in the context. 

0 votes
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.
February 11, 2025

Hi @Eliyahu Klein --CNTR 

That is likely possible by calling the REST API endpoint (with the Send Web Request action) to get the create issue metadata for the specific project and issue type, and checking if the "set" operation is available.  Other than checking for a single field, that seems quite elaborate just to prevent a rule error.

Another alternative is if you know the issue type, the rule could use dynamic JSON to add (or not add) the field.

Kind regards,
Bill

Eliyahu Klein --CNTR February 11, 2025

Hi @Bill Sheboy 

 

Thank you for your response. I appreciate the suggestions you provided. Could you please elaborate and provide examples on how to implement each of the two alternatives you mentioned?

  1. Using the REST API:

    • Could you provide a detailed example of how to set up the "Send Web Request" action to call the REST API endpoint and check if the "set" operation is available for a specific field?
  2. Using Dynamic JSON:

    • Could you explain where and how to use dynamic JSON to add (or not add) the field based on the issue type? An example would be very helpful.

Thank you for your assistance!

Kind regards,
Eliyahu

 

Eliyahu Klein --CNTR February 11, 2025

 

 

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.
February 12, 2025

I recommend performing the research necessary for either of these methods, and then experimenting to try them.  As a reminder, the Atlassian Community is a place for people to learn and collaborate.  It is not a source to provide turnkey solutions upon demand.  Please work with your Jira Site Admin to learn more.

 

Regarding sources to get you started trying those suggestions...

1) Please read this article on calling the Jira REST API endpoints from a rule: https://community.atlassian.com/t5/Jira-articles/Automation-for-Jira-Send-web-request-using-Jira-REST-API/ba-p/1443828

Then review the REST API endpoints to learn how to find the issue metadata: https://developer.atlassian.com/cloud/jira/platform/rest/v3/intro/

 

2) Using rule conditions or conditional logic, your rule could build a dynamic JSON expression for the specific fields, storing that in a created variable.  Here are some sources to help learn how to do that:

Eliyahu Klein --CNTR February 13, 2025

Hi @Bill Sheboy 

First of all, thank you very much for your help and guidance.
Secondly, You are right - I greatly appreciate research, testing, trial, and fix. This is also how I usually operate as a Jira admin.

The reason I asked for more details is that I am familiar with the methods you described and have used them in various cases. However, I couldn't figure out how to apply what you wrote to implement the solution.

  1. I know how to access the metadata and check what exists on a specific issue screen. I couldn't find a way to use automation to read the data and convert it into an "if" and "else" condition. Therefore, I asked for more specific assistance.
  2. If I build a JSON expression, it is likely to return a similar error message because it is also limited to the project's editing capabilities. Therefore, I wanted to understand better what you meant and how to build the JSON so that it does not return an error message.

Thank you very much for your help.

Best regards,
Eliyahu

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.
February 13, 2025

No worries, and here are more details:

After calling the REST API to get the metadata, use dot-notation and a conditional expression, or the match() function with regex, on the web response body to determine if the specific field is present, and if the desired operations are present.  Please try doing this incrementally, using the Log action to write results to the audit log as you start with just the web response, adding conditions / searches to it, until you get the desired result.

I have not needed this scenario before, and so I would essentially need to build and test it fully to offer more details.

 

For the JSON approach, that is simpler if you know a specific issue type does / does not support the field.  Then the JSON could be stored in a Created Variable for use.  For example:

  • action: create a variable, named varMyJson, with an initial value of {{null}}
  • if / else condition block
    • condition: issue type equals Story
    • action: create the same variable again, this time with valid JSON to set the field.  This will shadow the earlier variable
  • action: edit issue, and in the advanced edit, enter {{varMyJson}} for the JSON block

Suggest an answer

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

Atlassian Community Events