Getting the priority id in a scriptrunner behaviour

Deleted user February 5, 2018

Hi All

I have a behaviour which requires the users to provide a explanation when they set a high priority.

Before updating ScriptRunner, I was able to retrieve the ID of the set priority like so.

def priority = getFieldById(getFieldChanged())
def selectedPriority = priority.getValue()

But now, the variable selectedPriorty contains this and not just the ID anymore.

IssueConstantImpl[[GenericEntity:Priority][sequence,3][statusColor,#D31C1C][name,Hoch][iconurl,/images/icons/priorities/highest.svg][description,Dieses Problem könnte die normale Arbeit unter Umständen behindern.][id,3]]

How can I get the ID out of this string?

Thanks and best regards

Marius

1 answer

1 accepted

0 votes
Answer accepted
Alexey Matveev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 5, 2018

Try like this

def priority = getFieldById(getFieldChanged())
def selectedPriority = ((IssueConstantImpl) priority.getValue()).getId()
Deleted user February 6, 2018

Unfortunately, this throws the error:

unable to resolve class IssueConstantImpl
Alexey Matveev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 6, 2018

you need to add import

import com.atlassian.jira.issue.IssueConstantImpl

def priority = getFieldById(getFieldChanged())
def selectedPriority = ((IssueConstantImpl) priority.getValue()).getId()
Like # people like this
Deleted user February 6, 2018

Thanks a lot. Works :)

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events