You need to sign in to do that
Don't have an account?
Validation Rule to check checkbox
Good Morning Guys n Gals,
I was wondering if you all could possibly help me with a situation I am running into. I am trying to make my Active Contract field a "live" field if you will. I'll show you the code I have so far, then explain a little more;
IF (Contract_End_Date__c >= TODAY()) Contract_Start_Date__c <= TODAY() Active_Contract__c = 1,
IF (Contract_Start_Date__c >= TODAY()) Contract_End_Date__c <= TODAY() Active_Contract__c = 0
So basically you can see that I want this to check the Active Contract checkbox if the start and end dates on our accounts meet the correct criteria.
I'm pretty new to Salesforce, and seem to be getting syntax errors all over this.
Any help would be greatly appreciated.
Thanks in advance.
Can you post the exact code that you are using, along with a list of the Field Names and Data Types involved? I just tested it on my SFDC Dev Org and it worked fine:
Start Date: Datatype = Date
End Date: Datatype = Date
Status: Datatype = Formula(Text)
It sounds like some of your fields might be Datatype = Date/Time instead of Date, if that's the case you're going to have to convert them using a DATEVALUE function like this.
IF(AND(DATEVALUE(End_Date__c) >= TODAY(), DATEVALUE(Start_Date__c) <= TODAY()), "Active","Inactive")
All Answers
You can't create a Formula(Checkbox) field, but you can create a Workflow Rule with a Field update that will evaluate your record and update your Checkbox field from True (checked) to False (unchecked) as needed.
If you do need it to be a formula, then you could try making something other than a Checkbox, and make it a simple Formula(Text) or Formula(Number,0). Then you could have the formula set the field to "Active", "Inactive", "1", or "0" as needed.
That's exactly what I'm trying to do.
Anyway you could point me in the direction of creating a workflow :-" ...
I'm pretty new to Salesforce ... heh
Thanks again for your help guys n gals.
Okay, I have a couple of questions about your formula, could you spell out exactly what the conditions are? It's kind of hard to figure out if you're trying to say something like :
IF Contract_End_Date__c >= TODAY
AND
Contract_Start_Date__c <= TODAY
THEN Active_Contract__c = TRUE
Or you're trying to say:
IF Contract_Start_Date__c >= TODAY
OR
Contract_End_Date__c <= TODAY
THEN Active_Contract__c = FALSE
Create a workflow rule with the following formula
AND(EndDate>=TODAY(),StartDate<=TODAY())
The update part of the workflow should update "Active Contract" to "True"
I apologize for not being completely clear.
I'm just wanting to make it so if today's date falls into the range on the contract, I.E. Account was signed from 1/1/2010 - 1/1/2011, then the Active Contract box would be checked automatically.
So to answer your question Steve, it would be the first example;
IF Contract_End_Date__c >= TODAY
AND
Contract_Start_Date__c <= TODAY
THEN Active_Contract__c = TRUE
I was just a little mistaken, and thought that I had to have another statement to make it false for the opposite.
If you want it to be completely automatic, and not dependent on a user having to edit or update the record, you could created a Formula(Text) and use something this for the formula:
IF(AND(End_Date__c >= TODAY(), Start_Date__c <= TODAY()), "Active",
IF(OR(Start_Date__c >= TODAY(), End_Date__c <= TODAY()), "Inactive", NULL
))
Line 1 basically says "If the End Date is in the future AND the Start Date is in the past then it's Active"
Line 2 basically says "If the End Date has lapsed OR the Start Date hasn't arrived yet then it's Inactive"
Looking at your last reply, you could probably shorten it to something like
IF(AND(End_Date__c >= TODAY(), Start_Date__c <= TODAY()), "Active","Inactive")
hmm when I try to use that code
IF(AND(Contract_End_Date__c >= TODAY(), Contract_Start_Date__c <= TODAY()), "Active",
IF(OR(Contract_Start_Date__c >= TODAY(), Contract_End_Date__c <= TODAY()), "Inactive", NULL
))
It gives me :
Error: Incorrect parameter for function >=(). Expected DateTime, received DateSame with the shortened code.
The date fields are not custom fields. Try this formula
IF(AND(EndDate >= TODAY(), StartDate<= TODAY()), "Active","Inactive")
Can you post the exact code that you are using, along with a list of the Field Names and Data Types involved? I just tested it on my SFDC Dev Org and it worked fine:
Start Date: Datatype = Date
End Date: Datatype = Date
Status: Datatype = Formula(Text)
It sounds like some of your fields might be Datatype = Date/Time instead of Date, if that's the case you're going to have to convert them using a DATEVALUE function like this.
IF(AND(DATEVALUE(End_Date__c) >= TODAY(), DATEVALUE(Start_Date__c) <= TODAY()), "Active","Inactive")
Yeah you are correct. My EndDate/StartDate are date/time fields.
So can I use that code you provided with the existing date/time fields or do I need to remake the fields as just date fields ?
EDIT -- Nvm it works great. THANKS a ton for all the help.
I need a simple checkbox validation.
Fields like,
Is_Mandatory_c --- checkbox
First_Name_c --- text box
Now, i need a validation like:
When the user checked the Is_Mandatory check box, First_Name should be a mandatory field to fill.
So, could you please help on this.