I am trying to update our asset schema from a Jira issue. Other than groovy script, are there any other ways to accomplish this?
If I have to use groovy script, are there any help guides or instructions?
Thanks!
There are some built-in asset modification post functions. But they are fairly limited.
Scriptrunner will give you much more flexibility.
The HAPI scriptrunner framework makes these tasks a lot simpler than they used to be.
You can study this page: https://docs.adaptavist.com/sr4js/latest/hapi/work-with-assets-insight
But if you have some specifics, I can help you build a simple script to take a value from a custom field and update an attribute on a linked asset (as specified by another custom field. Here is a generic sample:
import com.riadalabs.jira.plugins.insight.services.model.ObjectBean
def assetCfName = 'Asset Custom Field Name'
def valueCfName = 'New Attribute Value Field Name'
def attributeToUpdate = 'Attribute Name To Update'
def assetObjectToUpdate = issue.getCustomFieldValue(assetCfName)
//asset cf can contain lists of object, let's assume you've restricted yours to single values (byt the API doesn't know that)
if(assetObjectToUpdate instanceof List){
//we found a list of objects (even if the list is size 1) let's take the first in the list
assetObjectToUpdate = assetObjectToUpdate[0]
}
def valueToSet = issue.getCustomFieldValue(valueCfName) as String
//"as objectbean" is not necessary, but it helps hide static type checking errors
(assetObjectToUpdate as ObjectBean).update{
setAttribute(attributeToUpdate, valueToSet)
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Crystal Rouse ,
Let me first ask your if you are on Cloud or Datacenter? The options could be different based on that :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.