You need to sign in to do that
Don't have an account?

Visualforce page with particular record type
I have a record type on the lead object that requires the email field to be hidden. Salesforce does not allow the email field to be hidden on the page layout of the lead object. I cannot use field level permissions to hide this field either, as the email field is used for other integrations. I just need the email to be hidden from users for this record type. I have a visualforce page that has everything I need. How can I have this page displayed when the lead is this particular record type?
<apex:page standardController="Lead" extensions="LeadOverrideViewController" action="{!navigateToNewRecordTypePage}"> <apex:detail subject="{!lead.Id}" relatedlist="true" rendered="{!NOT(isNewBusinessRecordType)}"/> </apex:page>
public without sharing class LeadOverrideViewController
{
public boolean isNewBusinessRecordType {get; set;}
public Lead lead {get; set;}
/*
* Constructor
*/
public LeadOverrideViewController(ApexPages.StandardController controller)
{
isNewBusinessRecordType = false;
this.lead = (Lead)controller.getRecord();
List<Lead> lstLE = [Select Id, RecordType.Name from Lead where Id =: lead.Id];
if(lstLE[0].RecordType.Name == 'New_Business')
{
isNewBusinessRecordType = true;
}
}
public PageReference navigateToNewRecordTypePage()
{
PageReference pg;
if(isNewBusinessRecordType)
{
pg = Page.myPage; // Replace it with your visualforce page
}
else
{
pg = new PageReference('/'+lead.Id);
pg.getParameters().put('nooverride', '1');
}
return pg.setRedirect(true);
}
}
Let me know if this works.