Hello!
I hope you can help me. I really don't know what I'm doing wrong.
My use case:
Everytime users are mentioned in a comment, I want to add them to the field "Shared With" (multi-user picker).
So first a list of matches in the comment is generated.
Then the list is iterated using advanced branching.
For every match the issue is supposed to be updated by adding a value to the Shared With field.
The rule works fine for the first occurrence of an account id in a comment.
But for the second one it says "specify a valid value for the field".
To give more context here are screenshots of the exact rule steps and the audit log
Hi @Jane D_
Welcome to the community.
Check this KB, update-values-in-multiuser-picker-field-using-automation-in-jira-cloud
There is no need to branch.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you very much!!
Now I'm encountering a different problem - I followed the exact syntax given in the link.
I get the error "Error while parsing additional fields. Not valid JSON."
I tried enclosing the account id to be added in extra brackets. But then I got "Specify a valid value for customfield..."
See pictures for both rule setup and audit log.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Jane D_
The JSON should be one string for the part (no carriage returns in this code, other wise it is seen as an additional rule):
{{#useraccountIDs.split(",")}}{"add": {"id":{{.}}}}{{^last}},{{/}}{{/}}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Very useful info! I tried no carriage returns in the part you mentioned. And I tried to remove ALL carriage returns. But it still says "Not valid JSON".
This is the exact JSON:
{"update": {"customfield_10047": [{{#accountIDs.split(",")}}{"add": {"id":{{.}}}}{{^last}},{{/}}{{/}}]} }
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Jane D_
I meant only the part from the customfield needs to be one line.
Codeneeds to be:
{"update": {
"customfield_10047": [
{{#useraccountIDs.split(",")}}{"add": {"id":{{.}}}}{{^last}},{{/}}{{/}}
]
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'm so sorry this is so cumbersome.
I took your exact same syntax.
I did 2 things (pics of both attached).
* My variable name is different from that in your code and I first forgot to adjust it. This generated an error "not the right format for updating a field", which was to be expected because the variable I want to iterate does not exist or is empty. My bad.
* Then, I adjusted the variable name correctly. I got this freaking "not valid JSON" error again.
The variable is definitely not empty (I added pictures again), and should be of the correct type (string list converted to array using split() function in the iterator).
It must be something about the formatting or characters in the JSON somehow, that's my only guess...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Jane D_
It could be my error.
Can you try the JSON:
{"update": {
"customfield_10047": [
{{#}}{"add": {"id":"{{accountIDs}"}}}{{^last}},{{/}}{{/}}
]
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Jane D_
This should be the correct JSON according to the KB
{"update": {
"customfield_10047": [
{{#useraccountIDs.split(",")}}{"add": {"id":{{.}}}}{{^last}},{{/}}{{/}}
]
}
}
But as this doesn't seem to work, might be worth contacting Atlassian Support
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I have a solution!
The documentation is indeed not quite correct!
The code needs to be:
{"update": {
"customfield_10047": [
{{#accountIDs.split(",").trim()}}{"add": { "id":"{{.}}"}}{{^last}},{{/}}{{/}}
]
}
}
The element in question needs to be put in additional quotes.
(And the support dev also added a trim() call which cannot hurt I guess)
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.