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
4,296,817
Community Members
 
Community Events
165
Community Groups

Scriptrunner - Get attribute value from insight object

Hi,
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

0 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

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Posted in Jira Service Management

Jira Service Management Documentation Opportunities

Hello everyone, Hope everyone is safe! A few months ago we posted an article sharing all the new articles and documentation that we, the AMER Jira Service Management team created. As mentioned ...

330 views 0 10
Join discussion

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