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
sankumsankum 

data loading

i hava two sobjects for that objects i want to store the the data at a time using apex code and visual force???

 

 

sivaextsivaext

Hi

 

1. are you want copy same data in both sObjects or different data?

 

1. if same data 

 

    create visualforce page on one object and create trigger on that object to copy this data into other object.

 

2. if different data 

      

     create custom visualforce page with all fields (both objects) , inside controller write a code to insert two sobject records.

 

 

sankumsankum

thanks siva

copy the same data to sobjects

i tried the trigger but i did't get that

can u have the sample code send to me please...

sivaextsivaext

Hi 

 

if same data

 

suppose you have two objects  A and B .

 

1. if you uploading data using data loader on object A , 

 

write trigge to copy same data into other object.

 

Note: put limit 100 for batch in data loader (safe side for governor limits);

 

trigger triggername on A {

    List<B> blist = new List<B>();

     for(A a:trigger.New) {

      B b= new B();

     b. name = A.name;

     b.status = A.status;

     blist.add(b);

}

insert blist;

}

 

2. if you creating manually A record, same code.

trigger triggername on A {

    List<B> blist = new List<B>();

     for(A a:trigger.New) {

      B b= new B();

     b. name = A.name;

     b.status = A.status;

     blist.add(b);

}

insert blist;

}