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
Forrest Muldune 36Forrest Muldune 36 

Show Button based on Condtion


All,

I created a custom button on an opportunity with the code below

/p/process/Submit?id={!Opportunity.Id}&retURL=%2F{!Opportunity.Id}

Is there a way to create a button using Visual force where this button will be displayed only if the Stagename = Sales Order ?

Does anyone have any visualforce code examples?


 
Pa1 KumarPa1 Kumar
Do you want to hide the button on Salesforce Standard detail page? If yes, then I don't think you can hide any custom button in a standard page.
But you can achieve in two ways:
1. Create two page layouts: Page Layout 1 (has no Button) --> will be enabled when Stagename != Sales Order 
Page Layout 2 (has your Button) --> will be enabled when Stagename = Sales Order.
You need to control the two page layouts via recordtypes, if required you might have to create new.
2. VF Page and use 'Rendered' method to show/hide your button.

If the above solution doesn't work, then please provide more information.
Forrest Muldune 36Forrest Muldune 36
The most important thing is to show the button when the Stagename = Sales Order in an Opportunity record. 

we are trying to avoid creating new page layouts and records types, as much as possible.

I appreciate your response.