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
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.