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
Gary ForemanGary Foreman 

Mandatory field validation rule

How could I force the "close date" to be mandatory when the "delivery stage" is equal to Closed, Customer Quit or Failed at the opportunity level?

Field Names:
Close Date: CloseDate
Customer Quit
Closed
Failed
Delivery Stage (picklist) FN: Delivery_Stage  API: Delivery_Stage__c

What I have so far:

AND(ispickval(Delivery_Stage__c,"Closed"), ispickval(Delivery_Stage__c,"Customer Quit"), ispickval(Delivery_Stage__c,"Failed"), (CloseDate =""))

Error: Incorrect parameter type for operator '='. Expected Date, received Text
Best Answer chosen by Gary Foreman
Maharajan CMaharajan C
Hi Gary,

Sorry i forgot to mention the below one.

Opportunity Close Date is Standaed Field which is Mandatory by defaulted in Salesforce. So before the custom validation rule the Standard  Rquired Fields checking will be fired by Salesforce. You are getting the standard required field error message.

So here you don't have to worry about the making the closedate as mandatory. But it is not possible to make the close date as mandatory based on some condtions it's always required.And No use of any Validation Rule here.

This Closeddate field will comes under the Always Displayed field in Pagelayout so you can't remove or can't make this field as Non Mandatory.
https://success.salesforce.com/ideaView?id=08730000000BqEzAAK
https://help.salesforce.com/articleView?id=000324084&type=1&mode=1

Thanks,
Maharajan.C

All Answers

Maharajan CMaharajan C
Try the below one:

AND(OR(ispickval( Delivery_Stage__c,"Closed" ), ispickval(Delivery_Stage__c,"Customer Quit"), ispickval(Delivery_Stage__c,"Failed")), ISNULL(CloseDate))


Thanks,
Maharajan.C
Gary ForemanGary Foreman
This did not seem to work or maybe I am doing something wrong. Close Date seems to be required even when Delivery Stage is not set. Is it because I am testing the validation rule from my Admin account and not a regular user or does it not matter? Thank you.

User-added image
Gary ForemanGary Foreman
It is not displaying the correct error either.

User-added image
Maharajan CMaharajan C
Hi Gary,

Sorry i forgot to mention the below one.

Opportunity Close Date is Standaed Field which is Mandatory by defaulted in Salesforce. So before the custom validation rule the Standard  Rquired Fields checking will be fired by Salesforce. You are getting the standard required field error message.

So here you don't have to worry about the making the closedate as mandatory. But it is not possible to make the close date as mandatory based on some condtions it's always required.And No use of any Validation Rule here.

This Closeddate field will comes under the Always Displayed field in Pagelayout so you can't remove or can't make this field as Non Mandatory.
https://success.salesforce.com/ideaView?id=08730000000BqEzAAK
https://help.salesforce.com/articleView?id=000324084&type=1&mode=1

Thanks,
Maharajan.C
This was selected as the best answer
Gary ForemanGary Foreman
Thanks for the help, Maharajan. I'm reading this thread: https://success.salesforce.com/answers?id=9063A0000019XgvQAE

"Its Standard Field and Mandatory you Cannot change the Setting to UnRequired.
The only way to change this is to use a custom visualforce page and controller to modify this functionality."

Is it still possible to do what I am asking or am I out of luck? If it is possible, how do I create this custom visualforce page?