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
sk_nsk_n 

how to insert values into one custom object from other custom object using trigger

hi Friends , i have custom Object in the filed values must me inserted into an object from another custom object  with  help one look up field 

example "Return Books" is a custom object

values that should be inserted are from "Borrowed Books " Object.

The fields are Return date,Book ID both are common in both fileds.

 

please, help me in solving this problem.

 

Thanks 

satya

 

Anu Raj.ax1269Anu Raj.ax1269

Can you please explain what you want. From where you want to do this insertion.

sk_nsk_n

hi friend,

Borrowed Book is an object which have values 

Return Book is another object in which if i save a record the corresponding values must be inserted into Return Book fields .

 

how to write trigger for this?

 

Anu Raj.ax1269Anu Raj.ax1269

 

 

for(Borrowed Book b : new.trigger){

 

    put into a set  ; // set for the same field lookup in Return Book 

    put in a Map; // map for the same field lookup in Return Book +  Borrowed Book all fields.

}

 

list Return Book = [select fields ------ from Return Book where field : set];

 

for ( loop throudg the list size of the Return Book ){

 

refer the fields you want to get the value from Borrowed Book to Return Book ;

insert ; 

 

}

 

 

Thanks

Anu