Get values for the field using webhook

Dmitry Alabyan
Contributor
April 2, 2024

Greetings, community!
I am searching for a solution to get all the option configured for a custom field via REST API.
A bit of context:
setting up an automation, where
WHEN option A, B or C is selected for the customfield in Main project
A corresponding task is created in project A, B or C

Hence the idea:
- send a web request for all the options of the field
- for each smart value with the body of the response compare if field input equals one of the smartvalue options
- trigger following processes

2 answers

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.
April 2, 2024
Dmitry Alabyan
Contributor
April 2, 2024

kind of. problem is - can't figure it out with contexts. cannot call them correctly so as to specify context id path
always get a 405

Dmitry Alabyan
Contributor
April 2, 2024

@Bill Sheboy even earlier:
my customfield has and ID 10071
even the request of rest/api/2/field/10071 leads me to 405 error

 

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.
April 2, 2024

The expression should look like this, such as called from a browser, substituting in your values:

Your Jira URL/rest/api/3/field/customfield_12345/context/67890/option

If this is for one context, you could call this manually to identify the value for that second id number (the context): 

https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-custom-field-contexts/#api-rest-api-3-field-fieldid-context-get

If it is multiple, you would need to identify the correct context for the call.

Dmitry Alabyan
Contributor
April 2, 2024

@Bill Sheboy call was rest/api/3/field/customfield_10071/context/
yet the response was 

{"errorMessages":["The custom field was not found."],"errors":{}}
Dmitry Alabyan
Contributor
April 2, 2024

could this be due to it being for a work management?
the custom fields from that project aren't also visible in administration

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.
April 2, 2024

That sounds likely, but I do not know as I am not using JWM.  My suggestions were targeting Jira Cloud features.

You could try searching in the developer community to see if there are related questions / solutions: https://community.developer.atlassian.com/

0 votes
David Foote
Contributor
April 2, 2024

I've found that in automation, in order to dynamically create a card in a project, you need to use the project ID as a smart value, rather than just the project name or project key. (i.e. if I create a variable called {{proj}} and set it to a key like "MH" it won't work, but if I set it to a id like "10015" it will)

With this being the case, I'd suggest either using a lookup table in your automation to link the field values to project ids or, if you have Premium, creating a table in Assets to do something similar.

This has the downside of not dynamically updating as values are added and removed from the field, but the upside letting you use human readable values in your field!


I've done this recently with a custom field, Teams, and an object in Assets that holds the values from the field along with a project id:

image.png

And then in the automation, I go lookup the Asset using AQL and use the value I get back from that to create a ticket in the appropriate project:

image.png

It would be probably easier to create a lookup table to do this but

1. A lookup table is stored per automation, so if I want to do similar things in different spots that is more tables I have to keep updated

2. I can extend the Asset schema to hold additional info that I can dynamically put in the created card, like Categorization, Labels, Assignee, or Priority.

Of course, if you don't have Premium, lookup tables are your only option!

Dmitry Alabyan
Contributor
April 2, 2024

that is a beautiful solution. though the downside of it not being dynamic is a dealbreaker

Dmitry Alabyan
Contributor
April 2, 2024

and @David Foote asset solution works for service management.
my context is work management, sadly

Suggest an answer

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

Atlassian Community Events