Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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

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

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