Hi guys,
I have custom field Viewers. It's an array of Jira users. One issue can have many users in Viewers field.
I need to add automation to add all users from parent Viewers to child Viewers.
Could you please help me to specify an additional field correct?
That's how I already did it:
But it doesn't work. Log says:
A couple of things to try would be to add a Log action before you set the field to see what that call to asJsonStringArray is returning.
Next, perhaps try just set it directly (without the coversion to the array) if both Viewers fields are list fields.
Best regards,
Bill
I agree with Bill, you should just try the built in function to copy value from Parent issue. It even has the option to "[x] Add to existing values" in case you don't want to overwrite any subtask viewers:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Bill Sheboy , thanks for the answer!
asJsonStringArray is returning list of users, for example:
triggerIssue.viewers.asJsonStringArray: ["testuser","samruk"]
I tried to set it directly:
{
"edit": {"viewers":"{{triggerIssue.viewers}}"}
}
And get an error in the log:
No fields or field values to edit for issues (could be due to some field values not existing in a given project)
So it still doesn't work(
Hi @Darryl Lee thanks for the advice. I can't choose field Viewers using Built-in function. That's why I use the Advice section. But I saw on your screen you could choose Viewers field, how did you do it?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You may need to use the custom field number/name in your JSON rather than the people-friendly name, Viewers. Please talk to your instance admin to learn the custom field name and then try that for the edit.
__Bill
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Are you running on Cloud, Server, or Data Center? If Server/Data Center, what version?
Here's what my Viewers custom field looks like:
Bill mentioned that you could talk to your instance admin to get the custom field name/number. Do you not have full global rights on this Jira instance, but just project? I wonder if that's the limitation you're running into.
https://confluence.atlassian.com/automation/permissions-for-project-automation-993924702.html
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Oh, I forgot to mention, I'm testing this on Cloud. I tried with just Project Admin rights, and could still see the Viewers field. Also, interestingly, it didn't seem to matter that Viewers is not on the Screens for my test project.
I guess one other thing to ask is whether Viewers are in a valid Field Configuration Context for your project.
I just restricted my Viewers field to a different project, and ... Nope, I still see the field. I'm at a loss. Maybe it's a Server/DC thing.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
How about this syntax which should iterate over the trigger issue's viewers and add their JSON using the id values:
{
"fields": {
"viewers": [
{{#triggerIssue.viewers}} { "id": "{{accountId}}" } {{^last}},{{/}} {{/}}
]
}
}
Here's the documentation on the advanced JSON edit:
https://support.atlassian.com/jira-software-cloud/docs/advanced-field-editing-json/
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Bill Sheboy thanks for the advice.
I've tried custom field number/name before, and it didn't work too.
Syntax which you wrote works! But unfortunately not as expected, it deletes all Viewers from a child task. Will try to modify it but I'm really not good in JSON so hope your link will help :) Thanks!
@Darryl Lee thanks for the answer. I use Server Jira, have admin rights. Viewers field is a Global custom field and available for all projects. I think you can see it because of the Cloud version.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Alena Samruk Sounds good... To help diagnose why the field is being cleared rather than filled, consider posting the new id values with the Log action rather than updating the field. That should rule out part of the cause.
{{#triggerIssue.viewers}} { "id": "{{accountId}}" } {{^last}},{{/}} {{/}}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Alena Samruk I was going to suggest reaching out to Support, because this is weird. But then I dug around. Is this a Next-Gen Project? As with many things (:-( that's probably the problem:
https://jira.atlassian.com/browse/JRACLOUD-75792
I wonder if "add" would work here, as documented in that bug. So then:
{
"update": {
"viewers": [
"add": {{#triggerIssue.viewers}} { "id": "{{accountId}}" } {{^last}},{{/}} {{/}}
]
}
}
If not, then maybe you could try *ALSO* iterate over the existing viewers:
{
"fields": {
"viewers": [
{{#issue.viewers}} { "id": "{{accountId}}" }, {{/}}
{{#triggerIssue.viewers}} { "id": "{{accountId}}" } {{^last}},{{/}} {{/}}
]
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
All,
I have validated that @Darryl Lee 1st option (shown below) does work for team-managed projects, while the first option does not.
{
"fields": {
"viewers": [
{{#issue.viewers}} { "id": "{{accountId}}" }, {{/}}
{{#triggerIssue.viewers}} { "id": "{{accountId}}" } {{^last}},{{/}} {{/}}
]
}
}
Thanks for the assistance, @Darryl Lee!
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.