+ Start a Discussion

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.





Anu Raj.ax1269Anu Raj.ax1269

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


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 ;