I have a customfield_11312 (single select dropdown) with values like clientName-clientId ex. google-112233.
In automation I have a variable (smart) that extracts the clientId from issue description.
Question: How can I find (extract/find id) and set the value for customfield_11312, having only the clientId? Didn't find a solution to search/iterate on the values of a customfield dropdown to find the correct value.
Hi @Andrei Margarint - just wanted to clarify, the options for customfield_11312 are things like:
And your Description field includes something like:
Id: 223344
And you want to match that against:
If you happen to be on Jira Cloud, well are a few options (heh).
If you do not have a lot of options, you could manually create a Lookup Table like this:
And then you could Edit the issue and set your custom field value to the smart value:
{{matchId.get(companyId)}}
Where {{companyId}} is the id you've parsed out of Description.
(My custom field is named "Single Select List".)
However I hate doing this manually. The REST API lets us get the list of options for a custom field, so I wondered if I could leverage my favorite hack, accessing the Jira API through the Web request action. (That link has the details on how to get a Personal Access Token that you'll need for the Authorization header.)
You'll need to do a little bit of digging with the API to figure out the correct URL. You should be able to open a link like this (substitute in your sitename) in a browser window (ideally with Firefox which presents JSON nicely, or with this Chrome JSON viewer extension):
https://YOURSITE.atlassian.net/rest/api/3/field/customfield_11312/context
This should return a JSON blob that includes the context id for your options, which you would then add to the URL:
https://YOURSITE.atlassian.net/rest/api/3/field/customfield_11312/context/YOURCONTEXTID/option
Once you have that, you can plug it into the Web request action, using the GET method. Be sure to check "Delay execution of subsequent rule actions until we've received a response for this web request":
For my testing I used a Manual trigger and manually input the company id. You're parsing it out from Description, so in later examples you'll see {{companyId} again.
From there it's a matter of using Advanced branching to iterate over each of the options returned in the API call, in the smart value {{webhookResponse.body.values}}, which we are referencing as option:
For each option, we do a comparison of the Id (which we extract with some text functions) against the {{companyId}}.
Here's how we extract just the id from the option value:
{{option.value.right(option.value.length.minus(option.value.indexOf("-").plus(1)))}}
If we get a match, we set the field value:
And... that's it!
I hope that you're on Cloud so you can get to try this. It's pretty cool.
Hi @Andrei Margarint - I was wondering if you had a chance to give this a try, or had any questions.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
As I know automation don't have feature like that. Only option as I see will be use conditions ex. if value is 112233 set google-112233 as a value.
Regards,
Seba
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.