Jira 8.26.1
Script Runner V 6.56
At Create getting error "Cannot Invoke method getStatus on a null object" at Create in Script Runner Behavior Script
import com.atlassian.jira.issue.*
import com.atlassion.jira.component.*
def issue = getUnderlyingIssue()
def IssueType= getIssueContext().issueType.name
def issuseStatus = issue.getStatus().getName()
def fixVersions = issue.fixVersions
I am not a scripter so any assistance on how to resolve the above error will be appreciated
I'm not currently in front of a console, but if not mistaken you are trying to get the status of an issue, before it's creation. No wonder it returns null. It doesn't yet have a status :)
What are you trying to do?
Understood so how do I not get the status at create?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
def issue = getUnderlyingIssue
def issueStatus = issue.getStatus().getName
So I think it is trying to get the status of the current issue
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You guessed it. Remove the following line
def issueStatus = issue.getStatus().getName
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I can't remove that line I need that getstatus line to get the status of the current issue.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
But it doesn't have a status yet. How is it possible to return something else but null?
Let's go again and I hope that you will figure it out:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I understand that at create issue the issue type and status are unknown. But the Behavior fires at the Create issue event. You really don't need to be condescending. You told me to remove the
def issueStatus = issue.getStatus().getName
I was just telling you that I need that line.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sorry if you misunderstood my reply. There wasn't any bad intention to it. The behaviour doesn't fire at the issue created event. The issue created event is fired as a post function after the transition takes place. You want to keep that line and that's fine. But to answer your initial question, you can't solve this problem, because that line, where you've placed it, will always return null.
If you describe your business requirement and what you want to achieve, I might be able to help you out.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
We are using a behavior to validate at certain states that the fix version is a valid delivery version. We want to use a behavior because when you use a validator on a transition the users can update the Fix version back to an invalid delivery in-between transitions in the edit screen
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.