Saturday 12 May 2018

Page Redirection on the basis of Record Type/Field (Classic)


I came across an requirement where I have redirect user to different pages on the basis of Record Type (redirection is possible on the basis of fieldvalue as well).

Lets take an example

Object : Account
Record Types:

  1.       Customer [opens in Standard detail page]
  2.     Partner [opens in Visualforce page]


when user try to access account record of type 'Customer' then Salesforce standard page should get open but accessing any account of type 'Partner', custom visualforce page should be open.

Controlling page-layout on the basis of record type is possible but we cannot open visualforce page on the basis of record type or field value. To achieve this functionality we have write some code and need to override standard view button.

To achieve this requirement we will create a visualforce page and apex class.

after creating page and controller now its time to override Account's View button.



Now when user view account of record type 'Customer' Salesforce standard page will open and for account of record type 'Partner' visualforce page will open.




same functionality can be achieved on the basis of field value.