+ Start a Discussion
Pankaj Chauhan 11Pankaj Chauhan 11 

how to auto populate a custom field in standard object which has lookup relationship with custom object

I have the similar requirement with Contract as an parent object with building section in it as a custom field which has a lookup relationship with custom object named Management.I want to autopopulate the field of Building section in contract object through the field of building section in management object.

i have write the code with the help of yours but it is not working.Kindly Help

trigger Management on Management__c (before insert, before update) {

    Set<id>ids=new set<id>();
list<contract>oplst=new list<contract>();
    For(Management__c b:trigger.new){
            ids.add(b.Building_Section__c); //lookup field to opportunity on bid__c
        list<contract >opp=[select id,name from contract where Building_Section__c=Null AND id in:ids];
        for(contract op:opp){
            for(Management__c bd: trigger.new){
        update oplst;
ANUTEJANUTEJ (Salesforce Developers) 
Hi Pankaj,

Are you getting any error as such or is it not executing the logic properly, also could you please elaborate the scenario you are trying to implement?

Looking forward to hearing back from you.