Hi I am a beginner on Salesforce.com Platform
I've written an Apex class:
public class FieldSetDemonstration {
public Resource__c merch { get; set; }
public FieldSetDemonstration() {
this.merch = getMerchandise();
}
public List<Schema.FieldSetMember> getFields() {
return SObjectType.Resource__c.FieldSets.Hello2.getFields();
}
private Resource__c getMerchandise() {
String query = 'SELECT ';
for(Schema.FieldSetMember f : this.getFields()) {
query += f.getFieldPath() + ', ';
}
query += 'Id FROM Resource__c LIMIT 1';
System.debug('Hello world debug log');
Resource__c res= Database.query(query);
System.debug('Hello World Debug log'+''+res.name);
return res;
}
}
this is a controller class in the visualforce page controller giving the right res.name value but in debug console i am getting only Hello world Debug log. Can any one please tell why its not showing res.name value in debug console. How to show it for debugging purposes?
ok finally i found instead of using res.name in System.debug() i have to use res.get('Name')
public class FieldSetDemonstration {
public Resource__c merch { get; set; }
public FieldSetDemonstration() { this.merch = getMerchandise(); }
public List getFields() { return SObjectType.Resource__c.FieldSets.Hello2.getFields(); }
private Resource_c getMerchandise() { String query = 'SELECT '; for(Schema.FieldSetMember f : this.getFields()) { query += f.getFieldPath() + ', '; } query += 'Id FROM Resource_c LIMIT 1'; System.debug('Hello world debug log'); Resource__c res= Database.query(query); System.debug('Hello World Debug log'+''+res.get('Name')); return res; } }
this code is working fine