What to do when there is problem in displaying field value on page.

Field may be hidden due to field level security or might be that it doesn’t contain any value. If this is the problem, then write following apex code:

 
/*showing whether contact.FirstName contains a value*/
public class DemoController {
public Contact contact;
public DemoController () {
contact = [Select Name from Contact][0];
System.assert(false, contact.Name);
}
}

/*If the field was hidden due to field level security and FirstName contains a value ‘Sandeep’ then it will display on page as*/
 System.AssertException: Assertion Failed: Sandeep

Published by Sandeep Kumar

He is a Salesforce Certified Application Architect having 11+ years of experience in Salesforce.

Leave a Reply