function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
viadeoviadeo 

Trigger to update Parent picklist from Child picklist

Hi 

 

how fire a trigger only if a certain value is not present in map .to be clear status 'inactive' on account must be actived only if status on contract is 'expiré ' and also if no contract with status'activé' exist.

 

this is my trigger without the second condition

 

trigger workflow2 on Contract (before update) {
List<Account>accList=new List <Account>();
set<id>accIds = new Set<id>();

for(Contract c:Trigger.new){
accIds.add(c.AccountId);

}
Map<id,Account>accMap=new Map<id,Account>([Select(select id,status from contracts)from Account Where Id in :accIds]);


for(Contract c:Trigger.new){
if(c.status=='activé'){
account ac=accMap.get(c.AccountId);
ac.A_I__c='active';
accList.add(ac);
}
if(c.status=='expiré'){
account ac=accMap.get(c.AccountId);
ac.A_I__c='inactive';
accList.add(ac);
}

//this trigger must be fire only if in contract Map ,value 'activé' isn't there 
}

update accList;


}