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
Community Members
Community Events
Community Groups

Access issue fields during Create


I'm trying to write a ScriptRunner Validator script that throws an error when the user did not link the issue (Defect) to a parent (Story) during the Create action.

I can't find a way to access the fields of the issue because at that point it's not stored in the database yet. How do I do that?

I know it can be done using a Behaviour, but in this case I'd like to use a Validator.


1 answer

1 accepted

Hi @Vikrant Yadav thanks - I actually did look at that one, but I couldn't get it to work because one of the methods gives me an error:


Any idea how to fix that?

This is on Jira 8.7.1 and SR 6.2.1

@Jozef Vandenmooter have you tried this one also :-


import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.IssueFieldConstants
import com.atlassian.jira.issue.fields.IssueLinksSystemField
import com.opensymphony.workflow.InvalidInputException
import webwork.action.ActionContext
import com.atlassian.jira.issue.MutableIssue;

MutableIssue issue = ComponentAccessor.getIssueManager().getIssueObject("")

def fieldManager = ComponentAccessor.getFieldManager()
def linksSystemField = fieldManager.getField("issuelinks") as IssueLinksSystemField

def request = ActionContext.getRequest()

if (request) {
def params = request.getParameterMap()
def issueLinkingValue = linksSystemField.getRelevantParams(params) as IssueLinksSystemField.IssueLinkingValue

for ( link in issueLinkingValue.getLinkedIssues() ){
def object=ComponentAccessor.getIssueManager().getIssueObject(link)
if(object.getIssueType().toString() != 'Initiative'){
throw new InvalidInputException(IssueFieldConstants.ISSUE_LINKS,
"Note: You must link this Deployment Request to a Initiative.")

@Vikrant Yadav, that one gives me the same error. Also, there's no need to define the issue, right? It gives me a warning issue is already a binding variable:


That code actually comes straight off of Adaptavist's Examples page:

I guess the API was changed since it was written.


Like Vikrant Yadav likes this

Turns out this is not a real error. It's incorrectly reported by the Static Type Checker as an error and can be ignored. The code works fine.

@Jozef Vandenmooter  Great, finally you get the working code. :)

I tested on my side also code was working even after giving error. 

Hi from the future

requestMap = ActionContext.getRequest()?.getParameterMap()
def blockingIsSet =
requestMap?.get('issuelinks-linktype') == ['blocks'] &&
requestMap?.get('issuelinks-issues')?.size() > 0


No need to import a bunch of unrelated stuff

Like # people like this

To also add, you may use the following :

if (object.getIssueType().name.toString() != 'Bug')

Following are the full object you can utilize:


Like Vikrant Yadav likes this

Suggest an answer

Log in or Sign up to answer

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