Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Unable to update asset attribute with type select

Bryan Spangler June 6, 2024 edited
First off, I am completely new to groovy script. I do have some coding experience (in college) So I am not as well versed in this as I'd like to be. 
We working on tracking our laptop assignments through Jira issues. Open a ticket to check it out and close the ticket to check it back in. I have an automation that kicks off a script to "check in" the computer. It updates our assets based on custom fields in an issue. But I have not been able to figure out how to update an asset attribute called Lifecycle, that is a Select type. As far as I've been able to find I should be able to update them by passing in a string ('In Production' below) while the rest of the attributes work (a user reference, and a boolean) the select list does not. The script is below. Any help would be greatly appreciated.
Thank you
def coAsset =  issue.getCustomFieldValue('Keytemp')
def asset = Assets.getByKey(coAsset)

asset.update{
    clearAttribute('Checked out to')
    setAttribute('Checked Out', false)
    setAttribute('Lifecycle','Recertification')
}

1 answer

1 accepted

1 vote
Answer accepted
Bryan Spangler June 6, 2024

I moved the setAttribute for 'Lifecycle' to the beginning of the update and it works now. No idea why this works but I guess I figured it out. 

Bryan Spangler June 6, 2024

Am still getting 

Script function failed on Automation for Jira rule: Laptop checkout, file: autocheckout.groovy, error: java.lang.NullPointerException: Cannot invoke "com.riadalabs.jira.plugins.insight.services.model.ObjectTypeAttributeBean.getType()" because "ota" is null
in the automation log. Anything I can do to get rid of this error?
Thomas Dupre February 12, 2025

Just came across this post - not knowing whether the problem still exists.

I got the same error in my automation. It means that Jira tries to access an object type attribute (ota) which cannot be found, e.g. because it does not exist or cannot be retrieved for other reasons (permissions?).

So in my case the reason was a simple typo in the attribute name. I fixed it and it worked.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
TAGS
AUG Leaders

Upcoming Jira Service Management Events