Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to set a custom field to the assignee

jtcours February 15, 2022

Hi everyone,

I'm trying to automate reassigning an issue in Jira as it moves through a couple levels of code review. When the issue moves from "To Do" to "In Progress", I'd like to automatically record the Assignee in a custom Author field.*

I've added Author, a custom person field, to the issue's template, but it's not appearing in the "Automation / Edit issue / Choose fields to set" dropdown. So I've been trying the advanced fields approach based on https://support.atlassian.com/cloud-automation/docs/advanced-field-editing-using-json/

Currently I get the error "COM-48 (data was not an array (customfield_10051))" using this:

{"fields": {"Author": {"id": "{{assignee.accountId}}"}}}

or this:

{"fields": {"author": {{ assignee.accountId.asJsonObject("id")}}}}

The error occurs regardless of whether or not I restrict Author to a single person.

What should I be doing differently?

*Background:

An issue will progresses through two levels of review. When it goes to level 1 review, I'd like the assignee to become the level 1 reviewer. If the level 1 reviewer sends it back to the author for review resolutions, the assignee should become the author. When the level 1 reviewer sends it to level 2 review, the assignee will be the level 2 reviewer. It's possible for the level 2 reviewer to send it back to the author for additional work, which is why I can't use "assign to previous": that would take it back to the level 1 reviewer, not the author. Hence the need for an author field to make sure the assignee can reliably go back to the author.

1 answer

1 accepted

1 vote
Answer accepted
Martin Bayer _MoroSystems_ s_r_o__
Community Champion
February 15, 2022

hi @jtcours welcome on the community. I just tested your use case and I can add field to Edit Issue action. It also works nicely when adding Assignee value to Author(s) field. So I think the best approach is to find out why your field cannot be used for configuration.

I have two questions

  1. Is your project of team-managed or company-managed type?
  2. If your project is of company-managed type, does your custom field have a correct context configuration?

 

My Edit Issue action configuration:

Screen Shot 2022-02-15 at 21.23.59.png

jtcours February 15, 2022

Hi @Martin Bayer _MoroSystems_ s_r_o__ , it's currently set as a team-managed project, but we're just learning Jira here, so it's possible something's misconfigured.

jtcours February 15, 2022

If it helps any, here are the field's settings:

Field.png

but the field does not appear in the dropdown for editing an issue:

jira_rule.png

Martin Bayer _MoroSystems_ s_r_o__
Community Champion
February 17, 2022

Hi @jtcours thank you for detailed description. It really helps :). I have one more question. Do you need to append  the assignee value to Author field or always just set/replace? If it is enough to replace it, you can use following advanced configuration. It is quite close to your first configuration:

{"fields": {"Author": [{"id": "{{assignee.accountId}}"}]}}
Like • 2 people like this
jtcours February 17, 2022

Thanks for the code, @Martin Bayer _MoroSystems_ s_r_o__ !

It's enough to replace it. I just need a way to get the assignee back to the original developer when transitioning out of review. 

I was originally creating the field at the project level. I found that, if I create the field at the global level rather than in the project, it appears in the automation dropdown. So I can configure the automation through the GUI as long as it's a global custom field.

Unfortunately now, when I try this code in the automation, the GUI complains about an unknown field. I wonder if there's some difference between global and project-level custom fields, at least for Person fields, that's getting mixed up in all this troubleshooting.

The other interesting thing is that a global Author field doesn't appear in the list of fields I can display in the issue itself, unlike the project-level one.

jtcours February 18, 2022

I'm going to mark this answer as the accepted one. I think between your approach and what I did, there's enough here to blaze a trail for the next person. Thank you very much for your help!

Martin Bayer _MoroSystems_ s_r_o__
Community Champion
February 18, 2022

Hi @jtcours thank you, one last note... you cannot use "global" custom fields in team managed projects, the implementation of the fields and the configuration is different.

Shaan Baviskar
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
June 6, 2024 edited

Hi @Martin Bayer _MoroSystems_ s_r_o__ Thank you so much for the config below.

{"fields": {"Author": [{"id": "{{assignee.accountId}}"}]}}

This is exactly what I've been trying to find for over 2 hours 🥹

In other threads, the solution is often presented as:

{ "fields": { "assignee": { "id": "{{initiator.accountId}}" } } }

 Which would always give the error "data was not an array"

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, jira product discovery, jpd premium, product management, idea management, product discovery, jira premium, product planning, atlassian community, product development, roadmap planning, product prioritization, feature management

Introducing Jira Product Discovery Premium ✨

Jira Product Discovery Premium is now available! Get more visibility, control, and support to build products at scale.

Learn more
AUG Leaders

Atlassian Community Events