0% found this document useful (0 votes)
53 views1 page

Recursive Function To Access Parent

The code defines a map to store child and parent geography classification IDs, populates the map by querying for classifications and their parents, and recursively calls a method to return the parent ID.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
53 views1 page

Recursive Function To Access Parent

The code defines a map to store child and parent geography classification IDs, populates the map by querying for classifications and their parents, and recursively calls a method to return the parent ID.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

Map<Id, Id> mapGC = new Map<Id, Id>();

List<Geography_Classification__c> listGC = [select id,


Parent_Geography_Classification__c from Geography_Classification__c];

if (listGC != null && listGC.size() > 0)


{
for (Geography_Classification__c gc : listGC)
{
mapGC.put(gc.Id, gc.Parent_Geography_Classification__c);
}
}

public void returnParent(Id paramId)


{
if (mapGC.containsKey(paramId))
{
Id idPGC = mapGC.get(paramID);
system.debug('id... ' + idPGC);

returnParent(idPGC);
}
}

returnParent('a11j0000003nftaAAA');

You might also like