+ Start a Discussion
Pranavaditya KannojooPranavaditya Kannojoo 

Retrieve fields values from list of sObjects dynamically

I have a list of sObjects and also know its field names. We need to retrieve these field values and build a custom object out of it. sObject.getSobject() returns an object and which needs to stored in various fields of the Custom Objects. The data types of fields in custom objects are LongTextArea, ID, Datetime. 

Any idea how to do this. 
Best Answer chosen by Pranavaditya Kannojoo
nbknbk
Basic example of dynamic sobject. It may help you.
http://forceguru.blogspot.in/2011/08/inserting-sobject-dynamically-in.html

All Answers

Pundareekam KudikalaPundareekam Kudikala
If you want hold different fileds from different object, you need to make use od Wrapper Class.

Please go though below example

https://developer.salesforce.com/page/Wrapper_Class
nbknbk
Basic example of dynamic sobject. It may help you.
http://forceguru.blogspot.in/2011/08/inserting-sobject-dynamically-in.html
This was selected as the best answer
Pranavaditya KannojooPranavaditya Kannojoo
Thanks this helps.
Ashish_SFDCAshish_SFDC
Hi , 


You can use the Describe callls to get the Fields' meta data dynamically and update the records using a upsert or update call in the new SObject. 

See the below link for further information on Describe Calls. 

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_dynamic_describe_objects_understanding.htm


Regards,
Ashish