+ Start a Discussion
Gina199Gina199 

Requiring input to a text field if check box field is TRUE

I have a custom object that contains these 2 fields:

 

1. Check box field Is Child?

2. Text Box Childs Name

 

If the Is Child? is checked I need to require the field Childs Name is filled in.  How can I do this?

 

 

Thanks

Best Answer chosen by Admin (Salesforce Developers) 
Aslam_Kamal_86Aslam_Kamal_86

You can simple add a Validation Rule on that object.

 

Something like IF(Is_child__c == true &&  LEN(Child_Name__c) == 0, true, false).

 

In this case if both conditions are true it will return true and an appropriate error message can be displayed.

 

 

All Answers

deepzdeepz

Hi,

 

I have a doubt in the requirement. Is the Child Name same for every record you create. If yes then it can be filled in with workflows in the following way:

 

 

Rule criteria : Is child?  equals true

 

Field Update:Childs Name. Use formula option to set the value

 

 

Now if the Child Name varies for each record and is dependent on another field maybe Parent,then we can use triggers as following.

 

 

if(Is_child__c==true)

 {

  if(Parent__c=="YY")

  {   

    Childs_Name__c = "YYYName";

   }

  elseif(Parent__c=="XX")

   {

     Childs_Name__c = "XXName";

   }

 }

 

the above solution is based on my assumption. Let me know if it solves your problem

 

Aslam_Kamal_86Aslam_Kamal_86

You can simple add a Validation Rule on that object.

 

Something like IF(Is_child__c == true &&  LEN(Child_Name__c) == 0, true, false).

 

In this case if both conditions are true it will return true and an appropriate error message can be displayed.

 

 

This was selected as the best answer
Gina199Gina199
Thank you this works exactly like I want it to!