Hello,
I'm jumping through the hoops necessary to export a list from a custom field, since custom field values aren't supported with #lookupissues. We have a field called Components Global that we use to store components across our whole Jira instance as we don't want to have to keep them synced between projects. I'm trying to print a list of all field values for Components Global within my queried tickets, scrubbed of duplicates.
My automation looks like this:
WHEN: Manual trigger
THEN: Lookup issues
AND: Create variable -
And: Create variable -
And: Send Slack message
This does work, but because this field is custom and I can't use ".name" or ".value" with it, I get everything Jira has to offer for each entry. They look like this:
[CustomfieldOption{self='https://[myorg].atlassian.net/rest/api/2/customFieldOption/10595', id=10595, value='AddressMonitoringAML'}],
What I want to keep in this instance is the "AddressMonitoringAML".
I've had to make do with several .remove() instances. The part that's really tripping me up is the URL and the id=##### portion. I don't want to remove every instance of every number from the results as there are some numbers that are part of a valid response. So, I'm trying to do something like:
.remove("https://[myorg].atlassian.net/rest/api/2/customFieldOption/#####")
I've tried using regex, stuff like \d{5}, to no avail. I've tried "...FieldOption/([0-9]{5})" and several permutations of that. Nothing seems to work.
Is there a character or string I can use to represent *any character* that I can use here??
If I could remove all numbers I'd use .replaceAll() but that's not valid here.
The answer is probably really simple and I'm gonna be upset when I find out, lol
Thanks!!
To back up a bit...the Lookup Issues action now supports all of the fields in issues which are supported by smart values in rules.
There are exceptions of unsupported fields, and you may learn which fields in your issues have supported smart values with this how-to article: https://support.atlassian.com/cloud-automation/docs/find-the-smart-value-for-a-field/
Perhaps try accessing what you need and write to the audit log first, before trying to parse things from a created variable. For example, you could try this if your field is a text field
{{lookupIssues.customfield_10297.distinct}}
If your field is a single select list, try adding value before distinct. If the field is multiselect, this will be more complex to solve, as there is no sort function in the lists. The work-around there is to sort first with your JQL feeding the Lookup Issues action.
Kind regards,
Bill
Hey Bill,
The field is multi-select. I don't quite follow what you mean in your last sentence, though, or by sort in this context. Do you mind elaborating? Sorry, and thanks for your help!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Whatever solution you had in mind is probably more elegant than the one I just found, but I *did* just get this working after about 6 hours of brute force whacking away. Still very interested in what you had to say as I'm not sure what I did makes a ton of sense, even if the results are right.
Here's the first way I iterated:
WHEN: Manual trigger
THEN: Lookup issues
AND: Create variable -
And: Create variable -
And: Send Slack message
This removed the URL, id tag, and all the additional fluff, but put every value in brackets and did not distinct them properly. I manually removed the brackets and added a trim clause for white space:
WHEN: Manual trigger
THEN: Lookup issues
AND: Create variable -
And: Create variable -
And: Send Slack message
This is producing a perfectly formatted list with no undesirable characters or information.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Well done! You might be able to do that in one statement by splitting the first created variable before the replaces, rejoining, and then using distinct. But that would be harder to maintain/debug if something goes wonky.
Regarding my "last sentence" suggestion...What I could not tell originally was: do you want each possible value from a drop-down (distinctly) or if the grouping-of-a-set of selected values (distinctly)? To do the second one, I was suggesting adding an ORDER BY yourCustomField to the JQL which feeds the Lookup Issues prior to using distinct.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.