You need to sign in to do that
Don't have an account?
Peace
Display only field values from every record of an object
Hi
Please help me in implementing following :
I dynamically create 'Select' query to fetch data from an object, as shown below
Public PageReference FetchObjectContents() { String query = 'SELECT...'; ObjectContents = database.query(query); system.debug('----ObjectContents-------' +ObjectContents); //Converting Query result to String String str = ''; for (SObject a : ObjectContents) { str += String.valueOf(a) + '\n'; } }
OUTPUT something like :
Account:{Name=Burlington Coat Factory, Id=001T000000pSG6rIAF} Account:{Name=General Motors, Id=001T000000pSf4cAIR} ...
I want OUTPUT as follows, ie. without Object name and Field name ( only field values )
'Burlington Coat Factory', 001T000000pSG6rIAF
'General Motors', 001T000000pSf4cAIR
OR is there any other way to fetch only field values dynamically.
Thanks in advance!!
Try this,
This will generate below result
for all field try this.
This will generate below result
All Answers
try like this,
for(objectAPIName obj: objList){
System.debug(obj.name+obj.id );
}
Hi,
I have a Generic Sobject type.
And the solution which u provided requires me to provide objectAPIName statically in my code, which is not the requirement.
Can u please provide a solution by modifying the code which i provided.
Thanks !!
Try this,
This will generate below result
for all field try this.
This will generate below result