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
anjuanju 

How to create field dependency between picklist and number/text field?

I have a picklist having values A and B (this field is sforce field. Not an scontrol field.)
While selecting value "A" I need to display a field(will be number or text field).
And while selecting value "B" I need to hide that field.
Any way to do it?
 
Thanks
MadhuMadhu

hai

According to my knowledge there is no picklist dependency in salesforce only field dependency is there

if u get any information pls send me the reply.

Regards

madhu

anjuanju

As per my understanding we can apply validation rule to the number/text field to make it dependent.

But by using validation we can't able to make the number field as visible/invisible. But we can stop user from entering value to number field.

If any body knows any idea other than this then plz let me know.

SuchitraSuchitra

Hi Anju,

Well you can very well do it. Use s-control to do that.

Thanks & Regards

SuchitraInsert Smilies

 

 

anjuanju

yeah Suchitra. We can do it using Scontrol. But for that I need to build Scontrol for whole page and I need to override new/edit button also.

But I don't want to build Scontrol for whole page. And I don't want to override standard buttons.

Picklist and Number fields are sforce fields. If we can use scontrol to create its dependency(without creating whole page in scontrol) then how we can do it? How I will call that scontrol?

SuchitraSuchitra
Anju as you say the s-control requires override of new and edit button and creating scripts for them. There is no other go. It is also not very tough doing it. This  cannot be done on field validation since that occurs only on save button's onclick event we would want it to happen on the selection index chage on the picklist rather.
 
Yes you can write an s-control for the picklist it is noting but an dropdown which gets its value from the on change event . You can write a function on the selection index change event.  
 
regards,
Suchitra
anjuanju
As per my understanding we can't able to toggle a field in sforce with out scontrol.
 
I have solved my problem by applying validation rule.
 
//this is for a number field

AND
( NOT ( ISNULL( number_field_name ) ), NOT ( ISPICKVAL( picklist_field_name , "A")) )

//this is for text field

AND
(NOT ( ISPICKVAL(picklist_field_name , "A")), NOT(TRIM( text_field_name ) ="") )

An error message will be displayed if user enter value in text/number field after selecting "B" from Type field.