function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Custom button only enabled on record detail page based on the condition


I having one custom object called Test__c and containig field are offer__c, DSM__c and DaysSubmitted__c.

Now the requirement is when offer__c < DSM__c && DaysSubmitted__c > 90, if meet this creteria then only the custom button will get enabled otherwise its always will be in disable mode. 

For that i have created one custom button called Need Approval.

Please let me know how i can resolve this.

Thanks in advance
Arun ParmarArun Parmar


You can create a visualforce page and add your button with your enable and disable criteria, now add this vf page on your record layout.
Like this-> 


<apex:commandButton action="{!save}" value="Save" id="theButton" disabled="NOT({!offer__c < DSM__c && DaysSubmitted__c > 90})"/>


Now your button will show on layout within your requirement.