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
Ryan Mastbergen 5Ryan Mastbergen 5 

Formula Field on Leads not calculating correctly

/* If the record type is either lead, non converted lead, or employer group lead AND
               email field is populated (not blank) AND
               the lead is less than a year old, this field should be true */
            IF( RecordType.DeveloperName = "Lead" || 
              RecordType.DeveloperName = "Non_Converted_Lead" ||
              RecordType.DeveloperName = "Employer_Group_Lead" &&
              (NOT ISBlank(Email)) &&
              (TODAY()-DATEVALUE(CreatedDate)<= 365),
              True,
              False
            )

Hello,

I have a checkbox formula field on the Lead object that is not functioning as expected.  I only want the checkbox to be true if the lead is less than a year old (plus one of the record types stated).  However, it's still marking the records that are older than a year true.  Any suggestions would be helpful.
 

Thanks!

Best Answer chosen by Ryan Mastbergen 5
AnudeepAnudeep (Salesforce Developers) 
Can you try the following? Please recheck the syntax
 
/* If the record type is either lead, non converted lead, or employer group lead AND
               email field is populated (not blank) AND
               the lead is less than a year old, this field should be true */
            IF( RecordType.DeveloperName = "Lead" || 
              RecordType.DeveloperName = "Non_Converted_Lead" ||
              RecordType.DeveloperName = "Employer_Group_Lead" &&
              (NOT ISBlank(Email)) &&
              (DATE(CreatedDate) > (TODAY()-365)),
              True,
              False
            )

Let me know if this makes any difference

I also recommend going through the following documentation

Using Date and Date/Time in Formulas