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
pramod pallewadpramod pallewad 

write trigger

I have two object 
1. Account
2. BCC (related object to acount)
Account has external id field "BCC customer code" and BCC object has field "BCC code" and "status".
Requirement : When BCC code status is active then only that BCC code should show in "BCC customer code" on Account detail page.
how to write trigger for this.
 
FARSANA PSFARSANA PS
Hai Pramod,
Try this trigger,
 
trigger Testtrigger on BCC__c(after insert,after update) {
    map<id,account> accountMap=new  map<id,account>([select id,BCC_customer_code__c from account]);
    list<account> updateAccount=new  list<account>();
    for(BCC__c bcc : Trigger.New) 
    {
        Account parentAcc= accountMap.get(bcc.account__c);
        if(bcc.status__c=='Active')
            parentAcc.BCC_customer_code__c=bcc.BCC_code__c;
        else
            parentAcc.BCC_customer_code__c=null;
        updateAccount.add(parentAcc);
    }
    if(updateAccount.size()>0)
        update updateAccount;
    
}

Hope this helps...