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

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

Avatar

1 badge earned

Collect

Participate in fun challenges

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

Challenges
Coins

Gift kudos to your peers

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

Recognition
Ribbon

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!

Leaderboard

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
4,559,332
Community Members
 
Community Events
184
Community Groups

How to get current issue object in Behaviour ?

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.
Mar 08, 2018

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

This helped, thanks @Alexey Matveev 

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)

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.

@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.
Mar 08, 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") 

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.
Mar 08, 2018

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

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.
Mar 09, 2018

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

@Suhas P 

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

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

Like Jordan likes this

Suggest an answer

Log in or Sign up to answer