I'm working with Jira Data Center 9.12.x.
I have created Asset objects. I have added an Asset Custom Field to my issue with the field configured to allow selection of only one object from the list.
I want to set the Summary field of the issue to the Name of the object. I know I can do this with an Automation Rule.
I'm trying to figure out if it can be done in a workflow post function.
The native Assets Post-Function appears to support copying asset data only to issue custom fields. It does not allow me to select the Summary field as the destination.
I have ScriptRunner, JWT, and JMWE.
With ScriptRunner I have tried to create a custom inline script to use with the Custom Script Post Function, but haven't found an example of code that has worked correctly for me to retrieve the Asset based on the information in the Asset Custom Field in the issue
I have tried this code:
def assetKey = issue.getCustomFieldValue("customfield_1234")
def assetObject= Assets.getByKey("${assetKey}")
I get back this error:
No object with key '[Name of object {object key)]' exists
I'm sure I have missed a piece of documentation or example that is readily available, but my Google searches so far have been unsuccessful.
Hi Trudy,
Asset custom fields are always stored as an array of objects - even when it is a single object field. What you need to do is to get the first object and then get the object's name. (you already have the object so you don't need to get it with Assets.getByKey.
Something like this:
def issue = Issues.getByKey("ABC-233)
def asset = issue.getCustomFieldValue("Assetfield")
def assetName = "No asset found"
if (asset?.size()>0) //check that there is a value in the field
assetName = asset.first().label
return assetName
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.