You need to sign in to do that
Don't have an account?
SKriLL
How to dynamcially build an object
How do I do something like this... Obviously fieldsetmemeber isnt the same as field, but it was the closet thing I could find to illistrate my point. I want to be able to build an object dynamically even if the numbers or names of fields changes. I could query the object and get a list of strings that are the names of the fields... but how do I turn that into a field reference?
for(Schema.FieldSetMember f : ObjectType.Custom_Object__c.FieldSets.Field_Set.getFields())
{
obj.f = datamap.get(f.getLabel());
}
for(String s : ListOfFieldsNames)
{
obj.s = datamap.get(s);
}
Bitcoin reward for a correct answer :)
for(Schema.FieldSetMember f : ObjectType.Custom_Object__c.FieldSets.Field_Set.getFields())
{
obj.f = datamap.get(f.getLabel());
}
for(String s : ListOfFieldsNames)
{
obj.s = datamap.get(s);
}
Bitcoin reward for a correct answer :)
http://forceguru.blogspot.in/2011/08/inserting-sobject-dynamically-in.html
http://www.oyecode.com/2012/03/dynamic-apex-creating-dynamic-objects.html