My Oracle Support Banner

Fetch Both Parent And Child Assets From Installed Base Asset Object Using Groovy (Doc ID 2887590.1)

Last updated on AUGUST 22, 2022

Applies to:

Oracle Fusion B2B Service Cloud Service - Version 11.13.22.04.0 and later
Information in this document applies to any platform.

Goal

On : 11.13.22.04.0 version, Service Request

Fetch both Parent and Child Assets using Groovy

The customer structure of Parent & Child Assets in Installed Base Asset object. They have a requirement for which we need to update both the Parent & Child asset attributes when a Service Request is marked as Resolved.

They have tried to write below script but the application is throwing an error stating ParentAssetId is not a valid field. They are able to see ParentAssetId in the REST API calls. If ParentAssetId is not available for Groovy then how can they get both Parent & Child assets?

if(isAttributeChanged('EffectiveDate_c') && isAttributeChanged('StatusCd') && StatusCd=='ORA_SVC_RESOLVED')
{
def assetID
def systems = [:]
def categorySystems = [:]
if(EffectiveDate_c != null)
{
def vo2 = newView('CseAsset')
def vc1 = vo2.createViewCriteria()
def vcr1 = vc1.createRow()
def vc4 = vcr1.ensureCriteriaItem('AssetId')
vc4.setOperator('=')
vc4.setValue(IBAssetId)
vc1.add(vcr1);
def vcRow2 = vc1.createRow();
def vc5 = vcRow2.ensureCriteriaItem('ParentAssetId');
vc5.setOperator('=')
vc5.setValue(IBAssetId)
vcRow2.setConjunction(0);
vc1.add(vcRow2);
vo2.appendViewCriteria(vc1)
vo2.executeQuery()
def nAssets=vo2.getEstimatedRowCount()
println('Total Number parent and child assets:'+nAssets)
while(vo2.hasNext())
  {
  def cRow = vo2.next()
  //assetID = currow.AssetId
  def systemActivationDate = cRow.AssetDFFVL?.issSystemactivationdate
if(systemActivationDate.toString() == null)
{
cRow.AssetDFFVL?.setAttribute('issSystemactivationdate',EffectiveDate_c)
}
  
  

  }
}
}
 

Solution

To view full details, sign in with your My Oracle Support account.

Don't have a My Oracle Support account? Click to get started!


In this Document
Goal
Solution


My Oracle Support provides customers with access to over a million knowledge articles and a vibrant support community of peers and Oracle experts.