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
aroyalaroyal 

Hide the Textbox Depending upon the Selection of Picklist Value

I need to hide Textbox or fields in Detailpage depends upon the Picklist values

 

I tried lot of methods. cant solve this

can we hide the fields in Record details page ??

anyone help me for this ?

 

 

MarkSilberMarkSilber

You can't dynamically hide or enable a text box based on a picklist (or any other field type for that matter) without using Visualforce. Record Types can drive different page layouts, but typically they are used when first creating a record, although you could allow users to change the record type after creation, which would then display the assigned page layout in Edit mode automatically.

 

The other option is to use Validation Rules to enforce data entry based on the value of the picklist -- but this means the field will always be visible and editable on the page layout.

aroyalaroyal

hi I got the solution ,

I writed a Trigger to change the Record type at save time

 

trigger ChangeRecordType on Lead (before insert,before update)
{
 for(Lead newLead : Trigger.new)
 {
   RecordType[] RecId = [Select Id, Name from RecordType where name =: 'Field Hide'];
   //Lead newLead;
   for(Integer i=0; i < RecId.size(); i++)
   {
    if(newLead.Rating =='Hot')
       {
          system.debug(RecId[i].id);
          newLead.RecordTypeId = RecId[i].id;
       }
       else
       {
       RecordType[] RecId1 = [Select Id, Name from RecordType where name =: 'Field Display'];
        newLead.RecordTypeId = RecId1[i].id;
       }
   }
 }

 
}

It works very well  , thanks Mark