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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root


1 badge earned


Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!


Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.


Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!


Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

How to set approver as the issue reporter via workflow post function?

I am trying to automatically set the Approver for service desk tickets to be the reporter via the transition into the approval status.

I've followed this: Custom Post Functions ( where it says all I should need is the following code:

import com.atlassian.jira.component.ComponentAccessor

def customFieldManager = ComponentAccessor.getCustomFieldManager()

def approvers = customFieldManager.getCustomFieldObjectsByName('Approvers')

issue.setCustomFieldValue(approvers, issue.reporter)

However, I get the error:

[Static type checking] - Cannot find matching method com.atlassian.jira.issue.MutableIssue#setCustomFieldValue

What am I doing wrong?

1 answer

1 accepted

0 votes
Answer accepted
Peter-Dave Sheehan
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 11, 2023

If you hover over the "getCustomFieldObjectByName" or approvers, you might see something about it being a list or collection.

And if you look at the name of that method, you will see that it is plural. 

These two things together mean "approvers" is actually a list of custom fields. And you can set a value on intended for a single field by giving it a list.

If you are confident you only have 1 custom field named "Approver", you can just add [0] at the end to get the "first item in the list of custom fields" returned by the method.

Then, I think you would still encounter another problem. I believe the "Approvers" field allows multiple values. As such, it will not like receiving a single user since it expects a list of users. So you need to give it a list, even if that list is a list of 1.

Try this

import com.atlassian.jira.component.ComponentAccessor

def customFieldManager = ComponentAccessor.getCustomFieldManager()

def approversCf = customFieldManager.getCustomFieldObjectsByName('Approvers')[0]

issue.setCustomFieldValue(approversCf, [issue.reporter])

Suggest an answer

Log in or Sign up to answer
AUG Leaders

Atlassian Community Events