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

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

Use a Post Function to Update the Priority Based on Multiple Custom Fields


I have looked and looked and tried to find this answer on my own, but I am coming up empty.  Please help me!

I keep getting this error:  groovy.lang.MissingPropertyException: No such property: customFieldManager for class: Script386.

I took the Adaptavist script, "Update Priority Based on a Custom Field," from the online library and tried to make it work as I need it, but this error persists.

Problem I am trying to solve is:  I have 6 custom fields.  All of them need to have the value of "No" then set Priority = Level 1.  If ANY ONE of the custom fields = "Yes" then set Priority = Level 2.  So, I tried to change their script to this (I'm sorry, I tried to use the code block, but I can't get it to allow my text to be copied in).  It's just not working.  Any suggestions?

import com.atlassian.jira.issue.IssueManager;
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.issue.fields.CustomField;
import com.opensymphony.workflow.InvalidInputException;
import com.atlassian.jira.issue.IssueManager;
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.config.PriorityManager;
import com.atlassian.jira.issue.customfields.option.LazyLoadedOption;

final String customFieldName = "1. Are you aware of any System issues that may have contributed to the problem?" || "2. Are you aware of any Communication issues that may have contributed to the problem?" || "3. Are you aware of any transition issues that may have contributed to the problem?" || "4. Are you aware of any Quality issues that may have contributed to the problem?" || "5. Was this problem not primarily related to the natural course of the request?" || "6. Is there anything else you would want us to know about this problem?"

CustomFieldManager cFieldManager = ComponentAccessor.getCustomFieldManager();
def customField = customFieldManager.getCustomFieldObjects(issue).findByName(customFieldName)

def customFieldVal = issue.getCustomFieldValue(customField) as LazyLoadedOption

def priorities = ComponentAccessor.getComponent(PriorityManager).priorities

def highestPriority = priorities.findByName("Level 2")
def highPriority = priorities.findByName("Level 1")

switch (customFieldVal?.value) {
case "Yes":
case "No":


1 answer

0 votes

You have used two different names for the "custom field manager" object.

When you've fixed that, I suspect you will find the switch fails because I suspect the fields are not string fields, and then the set value will fail because the priorties.findByName does not return an id.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Marketplace Apps & Integrations

🤺 Atlympic Event: Partnerships

Hello Community!  Quick disclaimer: We are running a contest on Community (The Atlympics!) from July 23rd - August 8th of 2021. If you are interested in participating in this contest (prizes! ...

56 views 0 2
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