How to get current issue object in Behaviour ?

Paridhi Agarwal March 7, 2018

Hi,

I am using JIRA version 7.2.9 and Script Runner version 5.0.4.

I want to set the Security Level for the current issue object in Behaviour. But I am not able to get the current issue object.

Can someone please help ?

3 answers

8 votes
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.
March 8, 2018

In behaviours you can either use the underlyingIssue variable or getIssueContext()

Slava Gefen May 10, 2023

This helped, thanks @Alexey Matveev 

1 vote
Larry Matter May 15, 2020

As @Kabelo Mokgoro  suggests, underlyingIssue is correct for a Behavior server-side script.

issueContext is not of type issue.

For example:
def wf = workflowManager.getWorkflow(underlyingIssue)

ragif.ahmadov May 21, 2020

i have same problem

my code is

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.MutableIssue;

def customFieldManager = ComponentAccessor.getCustomFieldManager()
def textCf = customFieldManager.getCustomFieldObjectByName("Client")
String clientName = underlyingIssue .getCustomFieldValue(textCf)

but i get error "the variable underlyingIssue is undeclared."

i have tried with issue. and then get error "the variable issueis undeclared." 

so can you help me pls.

Vedant Kulkarni July 21, 2020

@ragif.ahmadov  to get the field value you can directly use like this - 

String clientName = getFieldByName("Client").getValue()

no need for IssueContext. Just make sure the field should be present on the form/pop-screen

1 vote
Suhas P
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.
March 8, 2018

In actual script you can use 'issue' for current issue object.

 

For testing in script console you can use following,

import com.atlassian.jira.component.ComponentAccessor

def issueManager = ComponentAccessor.getIssueManager()

def issue = issueManager.getIssueObject("ABC-123") 

Paridhi Agarwal March 8, 2018

Hi,

I have already tried using "issue" object, but it is giving me the error 'the variable [issue] is undeclared'.

Please refer the logs attached.

Capture.PNG

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 8, 2018

That suggests that you have not used the last line of Suhas's code to get the issue.

Paridhi Agarwal March 8, 2018

I wan't to get current issue in Behaviour, in this case I will directly use 'issue' for current issue object (as depicted in screenshot below). Am I right ?capture2.png

Suhas P
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.
March 9, 2018

You should use 'issueContext' instead of 'issue'.

Vineela Durbha October 17, 2019

@Suhas P 

Have you tried to use issue context and got the results?

Kabelo Mokgoro October 31, 2019

@Paridhi Agarwal Have you tried using the "underlyingIssue" variable instead?

Like Jordan likes this

Suggest an answer

Log in or Sign up to answer