Hi
I am testing an automation that populates categories (a multiselect list) field based on input in another multiselect list.
The automation includes a lookup table to determine the categories to apply with the last step adding values to the category field using the following advanced edit:
{ "update": {
"customfield_12345": [{
"add": {
"value": "{{CategoryInput}}"
}
}]
}
}
The rule runs successfully however the edit step replaces all values in the custom field rather than append the list.
I assume this is due to how I have written the advanced edit.
Can someone offer some guidance please?
Screenshot of automation flow below:
Hi @Sean C-S -- Welcome to the Atlassian Community!
To clarify your scenario a bit, are you trying to copy values from one multiple-selection option field to another multiple-selection option field, perhaps translating the values in the process?
If so, your rule cannot use a branch to do so. The reason is branches which could be on more than one thing are run in parallel and asynchronously. And thus each pass through the loop will "walk over" the prior results, but in no particular ordering.
Instead you could use list iteration to pre-build the JSON needed in Create Variable, and then perform a single Edit Issue action with that variable.
Kind regards,
Bill
Hi @Bill Sheboy
Thanks for the response.
Your assumption is correct, the values are translated from on multi-select to another multi-select.
I have followed your advice and have removed the branching. My edit action now looks like this:
{
"update": {
"customfield_12345": [
{
"set": [
{{#customfield_67890}}
{{#if(ClientCategory.get(value))}}
{
"value": "{{ClientCategory.get(value)}}"
}{{^last}},{{/}}
{{/}}
{{/}}
]
}
]
}
}
The behaviour is different now, it appears to always set customfield_12345 to empty.
I added some log actions to see what was happening:
{{#customfield_67890}}Direct mapping for value {{value}}: {{ClientCategory.get(value)}}{{/customfield_67890}}
It seems as though the inputs are working, but when passed to the "ClientCategory.get(" they are passed as empty. This is reinforced by the fact if I remove the if statement, I get an error at the edit step which states that Option value '' is not valid (customfield_12345).
Any ideas?
Thanks again,
Sean
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Unfortunately, you may not use the lookup table for this scenario either. The reason is once inside of an iterator, no other data is accessible from outside. And so when you iterate over customfield_67890's value the lookup table cannot be accessed.
Instead you will need to use a series of conditional expressions. Let's assume you want to replace the values in customfield_12345, and so this would work:
{
"fields": {
"customfield_12345" : [
{{#customfield_67890}}
{ "value":
{{#if(equals(value,"valueA")}} "replacement of valueA" {{/}}
{{#if(equals(value,"valueB")}} "replacement of valueB" {{/}}
{{#if(equals(value,"valueC")}} "replacement of valueC" {{/}}
} {{^last}}, {{/}}
{{/}}
]
}
}
If you wanted to add the values instead, use the "update" syntax with "add".
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks @Bill Sheboy
I managed to get this working with some tweaks.
For any future visitors, this is what worked for me:
{
"fields": {
"customfield_12345": [
{{#customfield_67890}}
{{#if(equals(value,"valA"))}}{ "value": "replacement of valA" }{{/}}
{{#if(equals(value,"valB"))}}{ "value": "replacement of valB" }{{/}}
{{#if(equals(value,"valC"))}}{ "value": "replacement of valC" }{{/}}
{{^last}},{{/last}}
{{/customfield_67890}}
]
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Well done!
I almost suggested that approach, but erred on the side of removing any redundancy in the dynamic JSON building (and so extracted the "value" parts outside the conditional checks). I wonder: does your field contain any values other than "valA", "valB", or "valC"? If so, that could explain why my version did not work as expected.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
2 controls of Multiple selection dropdown
List A holds values such as (Winter, Summer)
List B -should Auto-populate on the basis of items from List A (List B holds list of fruits)
Winter =Grapes,Oranges
Summer =Mangoes,Watermelon
In detail , if user is selecting Winter from List A then, list b should be populate Grapes, Oranages
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Are you asking a new question?
If so, please create a new one using the "Ask a question" link at the top of this page...rather than adding on to this already resolved one.
Kind regards,
Bill
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey @Sean C-S , welcome to the Atlassian Community.
In the Edit request you will need to include the existing field value as well as the new value you want to add in the multiselect for it to be added and not replace the existing value.
Let me know if that works and I can support you to troubleshoot the automation.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for answering.
I'm not sure how I can achieve that in the branch since 1 - n values could be added.
Do i need to create a list (array I think) of all the values that are added and then add it in bulk maybe?
Thanks
Sean
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.