I have created one Custom Button same name as "Submit For Approval" I have choose the behavior as "Execute JavaScript"
I have created one extension class
public class AccountExtensionController
{
public Id accountId {get;set;}
public List accountList {get;set;}
public Boolean hideSubmitForApprovalButton {get;set;}
private ApexPages.StandardController standardController;
public AccountExtensionController(ApexPages.StandardController standardController)
{
this.standardController = standardController;
showHideButton();
system.debug('Check1');
}
public Boolean showHideButton()
{
accountId= ApexPages.currentPage().getParameters().get('id');
hideSubmitForApprovalButton =false;
system.debug('Check2'+hideSubmitForApprovalButton );
accountList =[select id, Ownership from account where id =: accountId];
if(accountList.size()>0)
{
if(accountList[0].Ownership == 'Private' || accountList[0].Ownership == 'Subsidiary')
{
hideSubmitForApprovalButton=true;
system.debug('Check3'+hideSubmitForApprovalButton );
}
}
system.debug('Check4'+hideSubmitForApprovalButton );
return hideSubmitForApprovalButton;
}
} VF Class
if ('{!Account.Ownership} == 'Private'' ) hideButton("Submit_For_Approval_Test"); function hideButton(Submit_For_Approval_Test) { try { var buttons = parent.document.getElementsByName(btnName); for (var i=0; i