You need to sign in to do that
Don't have an account?
Aman
String to Sobject
I have a list of type String which contains objects of Salesforce like Contact, Account, Opportunity,quote,case etc.
I want to convert the list of string in sObject to use the following line.
List<String> a=new List<String>();a.add(sObject.valueOf('Account'));
a.add('Contact');
a.add('opportunity');
a.add('Quote');
a.add('Account');
for(String x:a)
{
Map<String,sObjectField> fmap=Schema.sObjectType.x.fields.getMap();
}
// but it showing error. How i convert a string into Sobject.
the red color X is will be string from a list.....
You need to do it like this
I hope will help you , please ask if any confusion.
All Answers
why can't u take list of sobject type itself there?
You need to do it like this
I hope will help you , please ask if any confusion.
Thanks
:smileyhappy:
Your welcome Aman
http://salesforce.stackexchange.com/questions/41744/need-a-string-to-map-conversion-or-any-solution-for-below
USing Your Without using fieldset code i displayed all objects related fields dynamically in an visualforce page.But i con,t able gave Save functionality.Using below code i saved but record only created related object but record related information not saved.How to save object related record information also.
using below code i save object record in database dynamically. Schema.SObjectType targetType = Schema.getGlobalDescribe().get(strFieldName); SObject myObj = targetType.newSObject(); insert myObj;
Note:using above code related object record only created.
but I gave some fields information here but those fields information is not saved in this record How to save fields information also related object record Dynamically?
help meeeeeeeeeeeeeeeee..........
Here i am getting list of picklist fields of an account into list<string> (listObjectFields1).
for(string pickval:listObjectFields1)
{
system.debug('************'+pickval);// displaying all picklist fields
Schema.DescribeFieldResult fieldResult = Account.Industry.getDescribe();// here instaded of Industry i want to give pickval(it is not posible because it is a string ,so i want to convert this pickval to account type.)how can i please help me
system.debug('33333333'+fieldResult);
list<schema.picklistentry> values = fieldResult.getPickListValues();
system.debug('************'+values);
for (Schema.PicklistEntry a : values)
{
options.add(new SelectOption(a.getLabel(), a.getValue()));
}
}
See below link
http://gautamsfdc.blogspot.in/2013/01/display-multi-select-picklist-as-multi.html