Workflow rule - validation based on opportunity creation date

I need to validate an opportunity workflow rule based on the date the opportunity was created. For example the rule would only be valid if the creation date was before 03/10/2022.

Can anyone advise how/if this can be done?

Parents Reply Children
  • 0 in reply to Michele Gaw

    OK...I took a look at your script.  The field oppo_createddate contains date and time.  I believe this is why it is not working for you.

    The main take away is for the code you have above, you are comparing a date to a date/time so you may have to play with this script a bit...but I think it works. :-)

    For what you are doing, I would try this.  (Sorry I did not get a chance to test it.)

    Add .setHours(0,0,0,0) to the end of your date variable.  This will remove the time (hrs, min, sec, millsec)

    Place the below line between lines 2 and 3 of your script above...

    createdDate.setHours(0,0,0,0);

    There are a lot of different ways to handle the date, so if the above does not work.  There are another ways that will.

    This is a helpful reference on dates...

    www.w3schools.com/.../jsref_obj

    Hope this helps!!