Get Null values from custom fields that are populated with user ID in scriptrunner

Alex Sprague November 30, 2021

When I use the following script that I put together I am getting null values for the ApproversCFval and the and the ApprovalsCFval. It does populate the customfield_10557 with null-null.  the approversCFval should be a user id that i have confirmed is already populated with a user id value. 

 

Is this related to the customfield data type or how the script is written?

Is there a different way to pull a value from a custom field that is a user picker type? 

Also the ApprovalsCFval will be pulling from a custom field that has a approvals data type and that is also returning a Null value.

 

def projectKey = issue.fields.project.key
def issueKey = issue.key

// Get the issue object
def customFields = get("/rest/api/2/field")
.asObject(List)
.body
.findAll { (it as Map).custom } as List<Map>

def approversCFId = customFields.find { it.name == 'Approvers' }?.id
logger.info("${approversCFId}")
def approversCFval = customFields.find { it.name == 'Approvers' }?.val
logger.info("${approversCFval}")


def approvalsCFId = customFields.find { it.name == 'Approvals' }?.id
logger.info("${approvalsCFId}")
def approvalsCFval = customFields.find { it.name == 'Approvals' }?.val
logger.info("${approvalsCFval}")

def PostToField = customFields.find { it.name == 'AActionVAL' }?.val
logger.info("${PostToField}")

def resp = put("/rest/api/2/issue/${issue.key}")
.header('Content-Type', 'application/json')
.body([
fields: [
"customfield_10557": "${approversCFval}" + "-" + "${approvalsCFval}"
]
])
.asString()

 

Anyone have any insight into this?

 

Thanks in advance

 

0 answers

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events