You need to sign in to do that
Don't have an account?
Kenji778
create sObject of type defined at runtime
Hey all,
Simple syntax question here. When I need to create an sObject to be inserted, but I don't know what kind it will be ahead of time, how can I create an sObject of a certain type given a name? So say the string contact was passed in, how would I create a contact object? Thanks!
You can indeed do this, and the good news is there's not too much code involved:
All Answers
You can indeed do this, and the good news is there's not too much code involved:
Thank you sir, you are awesome. Just what I was looking for!
Try this :
Thanks
Ankit Arora
Blog | Facebook | Blog Page
Oh no! Not again.. This is a cross post :(
Thanks
Ankit Arora
Blog | Facebook | Blog Page
I think this should help you
here SObjectNameValue can be API Name of any object like it can be 'Account' , 'Contact'' or any custom object like MyCustomObject__c
for a example you can also see
http://forceschool.blogspot.com/2011/06/dynamic-binding-when-object-name-is.html
in this example I used Dynamic binding where object name was dynamic, you will see I have used 'Account' as hard coded as example but it can be passed by any parameter also .
Please ask me if any issue in it.
Snuck in before you Ankit :) Once again we posted the same thing, obviously on the same wavelength (and have no life, posting on sunday [evening in my case]).
@bob
shorter answers are best, I went for too much
Cross posts galore! I'm going offline so there'll be less for the next few hours :)
@shash - but we all posted the same method - always a good sign that its the correct way!
So true! Life is all about forcedotcom LOL!!
Thanks
Ankit Arora
Blog | Facebook | Blog Page
me too ,
@ankit please stay online so there will be some to see issues. :)
Funny! Good one Shashikant. I am always there :)
Thanks
Ankit Arora
Blog | Facebook | Blog Page