0

I need validation rule to stop users from editing Close Date if Opportunity is in "Commit" category, except Admin. But if the date changes in a range of current Quarter then it is okay to make change.

I have this:

and( ispickval( ForecastCategoryName, "Commit"), 
ischanged ( CloseDate ),
 $Profile.Name <> "System Administrator")

But I cannot figure out how to do allow edits in current Q range.

0

1 Answer 1

0

Something like this would work where you compare the month of the closedate to the month of today. A case statement replaces the mnoths into the 1,2,3,4 quarters and then you can compare the two. This compiled in my org but i didn't test that it worked. It should the case statement came from a Salesforce help article. "How to check if a date is in a given quarter"

AND(
 ISPICKVAL(ForecastCategoryName, 'Commit'),
 ISCHANGED(CloseDate),
 $Profile.Name <> 'System Administrator',
 CASE(MONTH(CloseDate), 
  1,1, 
  2,1, 
  3,1, 
  4,2, 
  5,2, 
  6,2, 
  7,3, 
  8,3, 
  9,3, 
  10,4, 
  11,4, 
  12,4,  98) =
 CASE(MONTH(TODAY()), 
  1,1, 
  2,1, 
  3,1, 
  4,2, 
  5,2, 
  6,2, 
  7,3, 
  8,3, 
  9,3, 
  10,4, 
  11,4, 
  12,4,  99)
)
1
  • Thank you Dan, I tried it in my sandbox, and It's not preventing any changes at all (i logged in as non admin user)
    – Lidiia
    Dec 4, 2019 at 14:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .