Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Field not returning correct value with the code

Deleted user April 24, 2018

I am trying to get value in my custom field(BCM Lookup) which is of type issue picker( this works similar to user lookup). Using below code but it doesn't return anything. 

But when i call BCM Test instead of BCM Lookup it returns correct value. 

##Code 

import com.atlassian.jira.component.ComponentAccessor

import com.atlassian.jira.issue.Issue

import com.atlassian.jira.project.version.Version

 

 

def customFieldManager = ComponentAccessor.getCustomFieldManager()

def epicLinkCf = customFieldManager.getCustomFieldObjectByName("Epic Link")

def epicIssue = issue.getCustomFieldValue(epicLinkCf) as Issue

def BCM = customFieldManager.getCustomFieldObjectByName("BCM Lookup")

 

 

if (epicIssue) {

    return (epicIssue.getCustomFieldValue(BCM))

 

}

Thanks,
Smriti

1 answer

0 votes
Deleted user April 26, 2018

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.project.version.Version

def customFieldManager = ComponentAccessor.getCustomFieldManager()

//Try to get the epic link value first
def epicLinkCf = customFieldManager.getCustomFieldObjectByName("Epic Link")
def bcmTestFieldCf = customFieldManager.getCustomFieldObjectByName("BCM Lookup")
def epicIssue = issue.getCustomFieldValue(epicLinkCf) as Issue

if(epicIssue)
{
return epicIssue.getCustomFieldValue(bcmTestFieldCf)
}else{
//No epic link value found so try the BCM lookup
def bcmLookupCf = customFieldManager.getCustomFieldObjectByName("BCM Lookup")
def storyIssue = issue.getCustomFieldValue(bcmLookupCf)

if(storyIssue)
{
return storyIssue
}else{
//Could not find either so return nothing
return ""
}
}

 

This returns value but doesnt return my parent value to BCM field.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events