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)
//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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
To begin with, I retrieve the Asset concerned.
//get asset incident
def incidentAssetCf = ComponentAccessor.getCustomFieldManager().getCustomFieldObject(XXXXX)
//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
}
}
//regex for extract real data of provider
def providerValueMatcher = providerValue =~ /\[(.*?)\]$/
def providerValueResult = (providerValueMatcher) ? providerValueMatcher[0][1] : null
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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!
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.