You need to sign in to do that
Don't have an account?
virk
Can someone help me in understanding this code what is this doing exactly
This is called from a trigger which passes the list of new map and old map.
public static void hierarchyAccountDeploiment(List<Account> accs, Map<Id, Account> oldMap)
{
List<Id> accIds = new List<Id>();
Boolean hasHierarchy;
List<Account> toUpdate = new List<Account>();
for (Account a : accs)
if (a.RecordTypeID == '012D00000002qdE' && a.R_seau_int_gr__c == true && a.Etat_relation_GEO__c == 'Déploiement' && (oldmap == null || oldMap.get(a.Id).Etat_relation_GEO__c != 'Déploiement'))
{
hasHierarchy = true;
accIds.add(a.id);
while (hasHierarchy)
{
List<Account> res = [SELECT id, Etat_relation_GEO__c FROM Account WHERE Etat_relation_GEO__c != 'Terminé' AND parentId IN :accIds];
accIds.clear();
if (res == null || res.size() == 0)
hasHierarchy = false;
for (Account aa : res)
{
accIds.add(aa.id);
toUpdate.add(aa);
}
}
}
for (Account a : toUpdate)
a.Etat_relation_GEO__c = 'Déploiement';
if (toUpdate != null && toUpdate.size() > 0)
update toUpdate;
}
Any help will be really helpful.
public static void hierarchyAccountDeploiment(List<Account> accs, Map<Id, Account> oldMap)
{
List<Id> accIds = new List<Id>();
Boolean hasHierarchy;
List<Account> toUpdate = new List<Account>();
for (Account a : accs)
if (a.RecordTypeID == '012D00000002qdE' && a.R_seau_int_gr__c == true && a.Etat_relation_GEO__c == 'Déploiement' && (oldmap == null || oldMap.get(a.Id).Etat_relation_GEO__c != 'Déploiement'))
{
hasHierarchy = true;
accIds.add(a.id);
while (hasHierarchy)
{
List<Account> res = [SELECT id, Etat_relation_GEO__c FROM Account WHERE Etat_relation_GEO__c != 'Terminé' AND parentId IN :accIds];
accIds.clear();
if (res == null || res.size() == 0)
hasHierarchy = false;
for (Account aa : res)
{
accIds.add(aa.id);
toUpdate.add(aa);
}
}
}
for (Account a : toUpdate)
a.Etat_relation_GEO__c = 'Déploiement';
if (toUpdate != null && toUpdate.size() > 0)
update toUpdate;
}
Any help will be really helpful.
Please check below comment
Let us know if this will help you