I have created trigger on Account object to update the address field based on billing repository object(Custom object).
When I update address in Billing repository
object it should be updated on account
object when the Account Status field="Active". If status field ="Inactive" it should not be updated on account object. The address details on account object is Custom formula field.
This is my code but its not working .Please can any one help me out at this issue.
trigger Rfleet_Accountaddress on Account (after insert, after update){
Set<ID> BilingId = new Set<ID>();
Set<ID> accids = new Set<ID>();
List<Billing_Repository__c> childRecords = [Select id,Name FROM Billing_Repository__c where id=:BilingId];
list<Account>acclist=[Select id,Rfleet_Id_Alcor__c FROM Account WHERE id in:accids];
for(Account acc:acclist)
{
for(Billing_Repository__c child :childRecords){
if(trigger.isInsert && acc.Status__c == 'Active'){
acc.Rfleet_Id_Alcor__c = child.Name;
}
else if(trigger.isUpdate && acc.Status__c == 'InActive'){
acc.Rfleet_Id_Alcor__c = '';
}
}
}
if(childRecords.size() > 0)
update acclist;
}
bilingId
andaccids
sets? they are emtpy ATM and nothing will be retrieved into your lists