You need to sign in to do that
Don't have an account?

Help with Dynamic SOQL
I was wonder how to create a dynamic soql statement with apex. I saved items in to an array but just don't know how to add them to the soql statement. The array looks like this:
My array will look like this: (First line is the object I created, second line is the name i want to put in, third line is the field name, and so on)
Person__c
John Doe
Name
27
Age__c
04/04/1988
Birth_date__c
Dallas
City__c
Saint Tom
Street__c
12345
Zip__c
Thanks for any help you can give.
thank you so much. My friend came did this:
newPerson.put(values[0], values[1]);
I was wondering how to send that one record in an email body? This is my send email method.
Thanks you for all your help.
All Answers
Hai,
I think you can directly insert like this,if suppose you splitted correctly,
You mean, Dynamic DML. You can do this by obtaining a token for the correct type of record, then adding the appropriate values to the object, and finally attempting an insert/upsert/update, etc. You can create a generic record like so:
sObject s = new Account();
Then, you can add fields to it dynamically:
s.put(fieldName,fieldValue);
Finally, when you are done, you can insert or update the record.
insert s;
Of course, if a field does not exist, it will throw an error at this point.
You can use getGlobalDescribe() and getDescribe() to determine legal field and object names. Please refer to the documentation for more information.
thank you so much. My friend came did this:
newPerson.put(values[0], values[1]);
I was wondering how to send that one record in an email body? This is my send email method.
Thanks you for all your help.