I have a custom button created whose logic which invokes a visualforce page. I have overridden the view button with a visualforce page that just displays the detail page of salesforce. The custom button is added to the detail page of the record.
View Page just has the below:
<apex:page standardController="object__c" extensions="controller">
<apex:pageMessages />
<apex:detail subject="{! object__c.id}"/>
</apex:page>
Controller logic:
public class controller{
private static final Map<String, ApexPages.Severity> severityMap = new Map<String, ApexPages.Severity>{'INFO' => ApexPages.Severity.INFO, 'ERROR' => ApexPages.Severity.ERROR, 'CONFIRM' => ApexPages.Severity.CONFIRM };
public object__c recVar{get;set;}
public String recordId;
public VFPage(ApexPages.StandardController controller) {
recVar= (object__c) controller.getRecord();
recordId = String.valueOf(sr.Id).substring(0, 15);
String pageMessage = ApexPages.currentPage().getParameters().get('pageMessage');
boolean doNotDisplay;
String referrer = ApexPages.currentPage().getHeaders().get('REFERER');
system.debug('############ the value ################' + referrer );
if(referrer.contains(recordId + '/e')){
doNotDisplay=false;
}else{
doNotDisplay=true;
}
System.debug('Do not display boolean %%%%%%%' + doNotDisplay);
ApexPages.Severity whatSeverity;
if(ApexPages.currentPage().getParameters().get('severity') !=NULL){
whatSeverity = severityMap.get(ApexPages.currentPage().getParameters().get('severity'));
System.debug('Severity %%%%%%%' + whatSeverity);
}
if (pageMessage != null && doNotDisplay) {
ApexPages.addmessage(new ApexPages.Message(whatSeverity , pageMessage));
System.debug('pageMessage Error **' + pageMessage );
}
}
}
The custom button has the reference to the below VF page:
<apex:page standardController="object__c" extensions="acontroller" action="{!makecallout}">
</apex:page>
The challenge here:
the challenge here is I want to disable the custom button based on a formula field value in the record. If the formula field return true I want to show the button else if it is false I do not want to show the button. How can I show and hide the button in the above VF page?