+ Start a Discussion
Renan Freitas 4Renan Freitas 4 

Hi all, I would like to know how I could hide fields in the visualforce of using as criteria the record type, in case it is a PDF file that I am generating and according to the record type some fields will be hidden Thanks in advance

Hi all, I would like to know how I could hide fields in the visualforce of using as criteria the record type, in case it is a PDF file that I am generating and according to the record type some fields will be hidden, Could you give me some suggestion or code for this?
Thanks in advance
Jithesh VasudevanJithesh Vasudevan
Hi Renan,

You can use the below code to change the record type if the record satisfies a certain condition,


trigger changeRecordtype on Opportunity (before insert,before update) 
{
  for(Opportunity op:Trigger.new)
  {
 
// give a condition here so that if it satisfies, it will change the record type to the specified one
    if(<condition>) 
    {
    
   
//give the record type Id to which the current record type is going to change
     op.recordtypeId='<RecordtypeId>';
    }
  }


Use a different record type and name it like Do Not Use or something and remove the fields you want from the page layout only  for that record type. Specify that record type id in the trigger.
You can give a condition like op.Sync_To_QuickBooks__c =true where Sync_To_QuickBooks__c is a checkbox.