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
domdickdomdick 

Trigger help...

Hello,

 

I am trying to figure out how to update the custom lookup field on custom object.

Process:

1. i have got random number like "2346" that match with Opportunity object --> booknumber__c

2. now i would like to update above booking number's Id to  memoryCh__c object --> relatedBookingNumber__c (lookup field)

3. how can i make sure trigger should work on batch insert/update as well.

 

Any help would be much appriciated with an exmaple!

 

Thanks,

Rajesh SriramuluRajesh Sriramulu

Hi,

 

We can update the Lookup field value throug ID only.

 

for eg:

 

con.Rate__c= rt.id;

 

wher con is contact and having lookup with rate__c custom object.

 

Regards,

Rajesh.

 

 

souvik9086souvik9086

Hi,

 

Try this

 

trigger UpdateLookUp on Opportunity(after insert,after update) {

List<memoryCh__c> memChObjList = new List<memoryCh__c>();

for(Opportunity opp : Trigger.new){

memoryCh__c memChObj = new memoryCh__c();

memChObj.relatedBookingNumber__c = opp.booknumber__c;

memChObjList.add(memChObj);

}

if(memChObj.size() > 0){

upsert memChObjList;

}

}

 

If this post is helpful please throw Kudos.If this post solves your problem kindly mark it as solution.

Thanks