You need to sign in to do that
Don't have an account?
get value of custom field from custom object
Hi,
I need get the values of custom fields from custom object using sObject.
I have tried with below code
Employee__c account = new Employee__c();
Map<String, Schema.SObjectType> sobjectSchemaMap = Schema.getGlobalDescribe();
//The describeSObjects() call returns an array of DescribeSObjectResult objects.
Schema.DescribeSObjectResult objDescribe = sobjectSchemaMap.get('Employee__c').getDescribe();
Map<String, Schema.SObjectField> fieldMap = objDescribe.fields.getMap();
for(Schema.SObjectField fieldDef : fieldMap.values())
{
Schema.Describefieldresult fieldDescResult = fieldDef.getDescribe();
String name = fieldDescResult.getName();
System.debug(name);
System.debug(account.get(name));
}
here I m able to get the custom fileds but not values.
Plz suggest....
Thanks....
All Answers
Thanks for reply...
For this initialise this account object with a SOQL.
could you just give sample syntax.
If we use SOQL statement, In future if we add any new custom field we need to change the SOQL rt?
So with out going to change apex class Is there any other approach?
Please suggest....