Skip to main content
I'm trying to write a validation rule that prevents users with a certain role from creating events that take place in the past. Here's my rule so far:

 

AND(CreatedBy.UserRoleId = "00Ej0000001ITtG",

 

        ActivityDateTime < NOW(),

 

        CreatedDate = NOW())

 

If I take the third criteria out, an event with a start/end date in the past can be created, but then I get the validation when I edit it. How can I set it up so it stops the event from being inserted?
2 respostas
  1. 8 de fev. de 2017, 19:26

    Hello Micah, you can use this:

    AND(

      ISNEW(),

      $UserRole.Name = "Role Name",

    ActivityDateTime < NOW(),

    )

     

    • ISNEW() function ensures that the rule only fires on new records. 
    • The only other piece of advice I have for you is to always use Name/Developer Name (API) for the field names instead of harcoding ID's since ID's change between environments and that can cause serious issues post deployment.

     

    Jsut my 2 cents.
0/9000