Here is the automation setup which updates a Customer ID field based on customer names using a lookup table:
The field 'Customer(s)' is a multi-select list and could contain one or more customer names.
The Customer ID field is a single line text field.
I'm trying to append the Customer ID field with the IDs separated by comma. Any advise is appreciated.
Thank you.
Hi @keerthi
For your scenario you describe:
The only way to perform that translation (name to id) to then load the CSV list is with inline replacements, such as this assuming customer names of ABC and DEF with associated ids of 123 and 456.
{{issue.Customer(s).value.join(",").replace("ABC","123").replace("DEF","456")}}
Repeating the replacements for each customer name / id pairs. That is going to prone to errors and maintenance-heavy to support.
Perhaps a better approach would be to combine the fields, and parse out the things you need. For example, the values in the multiple select list could be:
(Yes, I know this combines two pieces of information in one field, for the DBAs taking note :^) When the names (or ids) are needed elsewhere in rules, text functions can extract them.
More details:
The lookup table action seems like it would be a good approach for this scenario, but rule iterators cannot access information from outside. That is, this cannot work...
{{#issue.Customer(s)}}{{customerId.get(value)}}{{^last}},{{/}}{{/}}
The lookup table cannot be seen once inside of the iterator's scope.
Kind regards,
Bill
Hi Bill,
Your solution to combine strings would be the solution I will go for.
Could you help me figure out how to extract a substring from the list item. I could find documentation on list functions and text functions but not sure how to combine the two.
For context, I've updated the 'Customer(s)' values to now include Name - ID.
I tried logging the following: {{issue.Customer(s).substringAfter(" - ")}}
But it returns a blank.
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.
You almost have it; the missing part is to select the values for the field.
{{issue.Customer(s).value.substringAfter(" - ")}}
This will produce a list of values.
As you wanted to put these into a text field as CSV, one addition would be this:
{{issue.Customer(s).value.substringAfter(" - ").trim().join(",")}}
That will removing any additional whitespace characters, and then join the list into a single text string.
If that does not work, the smart value "Customers(s)" may be incorrect for the field.
Smart values are name, spacing, and case-sensitive. And often the smart value does not match the displayed field name on the issue views. These steps can help to identify the correct smart value (and custom field id) for the field.
The essential steps are:
https://<yourinstanceurl>/rest/api/2/issue/<issuekey>?expand=names
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Use the "join" function of lists. The smart value would look like this:
{{issue.Customer(s).join(",")}}
See Jira smart values - lists | Cloud automation Cloud | Atlassian Support for more information
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.