Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Automation: Advanced field editing for adding to array

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:

Screenshot_5.png

 

 

But it doesn't work. Log says:

Screenshot_6.png

 

1 answer

Hi @Alena Samruk 

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:

Screen Shot 2021-01-07 at 1.13.28 PM.png

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?

Screenshot_7.png

Hi @Alena Samruk 

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

@Alena Samruk

Are you running on Cloud, Server, or Data Center? If Server/Data Center, what version?

Here's what my Viewers custom field looks like:

Screen Shot 2021-01-11 at 9.12.39 AM.pngBill 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

Like Bill Sheboy likes this

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.

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/

Like Darryl Lee likes this

@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.

@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}},{{/}} {{/}} 

@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}},{{/}} {{/}}
]
}
}

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Jira

Announcing the waitlist for Jira Work Management

Hey there Cloud Community members! We’re excited to give you the first glimpse of the new home for business teams on Jira — Jira Work Management. Jira Work Management is the next generation of J...

750 views 12 19
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you