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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root


1 badge earned


Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!


Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.


Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!


Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

Scriptrunner - Get attribute value from insight object

I'm looking to retrieve an unlabeled attribute (name is provider, id is 1293) from an insight object entered in a form (name is incidentAsset, id is 10706). What is the easiest way to find the value of a asset attribute ? I tried several methods found on the internet but without success.

//get asset incident (this part works)

def incidentAssetId = ComponentAccessor.getCustomFieldManager().getCustomFieldObject(10706);
def incidentAsset = issue.getCustomFieldValue(incidentAssetId)
_log.warn "Asset : " + incidentAsset

//get provider (attribute of selected asset, this part don't works)
def providerValue = objectFacade.loadObjectAttributeBean(incidentAsset.getId(),1293).getObjectAttributeValueBeans()[0].getValue()
_log.warn "Provider : " + providerValue

1 answer

1 accepted

2 votes
Answer accepted
Hello everyone,

My need was met by working with the editor's support team,
Hoping that this may also help you,
- 10706 : is a id of insight objet
- Povider : is a attribute of the insight object
    //get asset incident
    def incidentAssetCf = ComponentAccessor.getCustomFieldManager().getCustomFieldObject(10706)
    def incidentAssetValue = issue.getCustomFieldValue(incidentAssetCf)

    //get provider, the attribute insight of selected asset
    def getProvider = issue.getCustomFieldValue(incidentAssetCf) as List
    def getProviderIds = getProvider*.getId()
    def attributeValues = []
    getProviderIds.each {
        def providerAttribute = objectFacade.loadObjectAttributeBean(it, 'Provider')
        //management of empty fields, otherwise an error appears
        if (providerAttribute != null) {
            def providerValue = providerAttribute.getObjectAttributeValueBeans()[0].getValue()
            attributeValues << providerValue
        else {
            def providerValue = "N/A"
            attributeValues << providerValue    
    def providerToDescription = "Provider : " + attributeValues

Hello @vpass . Thank you for sharing this! I'm not able to get it to work. May I ask what version of Jira you were using (Data Center, Server, Cloud) and what context you used this in (post function, other)? Sincere thanks.

Indeed, the script has since evolved on my side.
(it's in DATACENTER, with scriptrunner 8.9.0, in a postfunction workflow script)
To return quickly to the subject: first of all, we're going to associate an Asset with a Ticket, and then use the script to find one of the attributes of the Asset concerned. 
The name of the attribute searched is called here 'Provider'.

To begin with, I retrieve the Asset concerned.

//get asset incident
def incidentAssetCf = ComponentAccessor.getCustomFieldManager().getCustomFieldObject(XXXXX)
It would seem that it's necessary to use arrays, even if the field that selects an asset can only show one value. I'll then retrieve the attribute value with "loadObjectAttributeBean". I then retrieve the [0] element with getObjectAttributeValueBeans and I also take care of empty values.
//get provider, the attribute insight of selected asset
def getAsset = issue.getCustomFieldValue(incidentAssetCf) as List
def getAssetIds = getAsset*.getId()
def providerValue = [] as ArrayList<ObjectBean>
getAssetIds.each {
    def providerAttribute = objectFacade.loadObjectAttributeBean(it, 'Provider')
    //management of empty fields, otherwise an error appears
    if (providerAttribute != null) {
        def getProviderValue = providerAttribute.getObjectAttributeValueBeans()[0].getValue()
        providerValue << getProviderValue
    else {
        def getProviderValue = "N/A"
        providerValue << getProviderValue
Then I parse the raw data with the regex. Then I store its contents as text for further processing.
//regex for extract real data of provider
def providerValueMatcher = providerValue =~ /\[(.*?)\]$/
def providerValueResult = (providerValueMatcher) ? providerValueMatcher[0][1] : null
(note that there would surely be simpler and more optimized)
Remember to load the necessary plugins at the start of the script, such as ObjectFacade Insight from riadalabs.
Hope this helps a little.
Have a nice day.

Sincere thanks! With your assistance, I was able to get this working. I truly appreciate you taking the time to not only share but also explain your code/logic. All the best!

Suggest an answer

Log in or Sign up to answer
AUG Leaders

Atlassian Community Events