+ Start a Discussion
tywalker2276tywalker2276 

Help Needed with Field Dependency

Does anybody know of a way to write a formula for the following scenario:

 

I currently have a field labeled "Assumption".  This field is a picklist with "Yes" and "No" options.  Should I choose "Yes", I would like a new field to appear titled "Original Closed Date" so that the user can populate this field.  Should I pick "No", I would like this "Original Closed Date" field to remain hidden so that the user doesn't have to bother with data entry on this field. 

 

Is this possible?  Any ideas or suggestion I could get would be much appreciated!

 

Thank you!

 

Tyler

Best Answer chosen by Admin (Salesforce Developers) 
SporterSporter

 You wouldn't be able to disable it per-say but you can make it either inputable based on either option but you'd be better off with two validation rules for this as two different errors would make sense.

 

So first Validation rule would be (If Assumption = Yes and Original Close Date is empty, give an error on saving the record)

 

 

ISPICKVAL(Assumption__c, "Yes") && ISBLANK(Original_Close_Date__c)

 

You'd then have an error message saying "Please fill in an Orgiinal Close Date" or something along those lines.

 

Next Validation rule would be this (If assumption = No and Original Close Date is populated, give an error on saving the record)

 

 

ISPICKVAL(Assumption__c, "NO") && NOT(ISBLANK(Original_Close_Date__c))

 

You'd then have an error message saying "You are not permitted to enter an Original Close Date, please change Assumption if this is required"

 

If any of the above doesn't work let me know what errrors you get.

 

All Answers

Learn CodingLearn Coding

Hi Tyler,

 

I dont think you might need a formula for this scenario. You could rather use filed dependencies to achive this. Go to your custom object detail page, scroll down to custom fields section, and click on field dependencies button. Now create a new Dependency, in your case the controlling field would be Assumption and the dependent field would be Original Closed Date.

 

Thanks,

Learner

tywalker2276tywalker2276

Hi Learner,

 

I tried to create that new Dependency with the controlling field being "Assumption" and the dependent field being "Original Closed Date", however the "Original Closed Date" is not a picklist field and thus wasn't available as a option for the dependent field.  Is there any way to make the "Original Closed Date" field available as an option for a dependent field?

 

Maybe better said, basically when I choose "Yes" from the "Assumption" field I would like the "Original Closed Date" field to be enabled so that the user must enter a valid date.  If the user chooses "No" from the "Assumption" field I would like the "Original Closed Date" field to be disabled. 

 

Any other ideas?

SporterSporter

 You wouldn't be able to disable it per-say but you can make it either inputable based on either option but you'd be better off with two validation rules for this as two different errors would make sense.

 

So first Validation rule would be (If Assumption = Yes and Original Close Date is empty, give an error on saving the record)

 

 

ISPICKVAL(Assumption__c, "Yes") && ISBLANK(Original_Close_Date__c)

 

You'd then have an error message saying "Please fill in an Orgiinal Close Date" or something along those lines.

 

Next Validation rule would be this (If assumption = No and Original Close Date is populated, give an error on saving the record)

 

 

ISPICKVAL(Assumption__c, "NO") && NOT(ISBLANK(Original_Close_Date__c))

 

You'd then have an error message saying "You are not permitted to enter an Original Close Date, please change Assumption if this is required"

 

If any of the above doesn't work let me know what errrors you get.

 

This was selected as the best answer
tywalker2276tywalker2276

Sporter!  Thank you so much!  That worked perfectly!  I would have been dead without you.  Thanks for the help. 

 

Now as a side question do you know how to prevent duplicate contacts from being entered?

SporterSporter

That would probably need and APEX trigger/class which goes over my head (at the moment) try google and the APEX boards here.

tywalker2276tywalker2276

Ok, thanks!