Show dynamic VisualForce page based on a field value in Salesforce.

  • In order to achieve the requirement, create a custom button and set the Behavior picklist to option ‘Execute JavaScript’ and Content Source picklist to ‘OnClick JavaScript’.
  • Add the below lines of code in Custom button Editor Text page:

  • Here, I am showing the custom VF page based on the values present in RecordType.
  var url='/apex/ApplicationTemplate';, '_self');
else if('{!Position__c.RecordType}'=="Sr.Developer")
  var url='/apex/Template2';, '_self');
  • We can pass the parameters as well, then the below code will look like below:
var url='/apex/Template2?id={!Account.Id}';, '_self');

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s