Forum Discussion

DavidGonzales's avatar
DavidGonzales
Qrew Member
5 years ago

OR in a Custom Data Rule

Hello...not the most experienced person with QuickBase, but I am trying to build a Custom Data Rule to prevent any employee from entering a time not in our current work week. It works fine, until I add the OR statement to allow me OR my manger to be able to make an older entry. (It works fine if I only name one of us, but fails with both names. The first part with the End and Start times works fine also.)

If([End Time]<[Start Time], "End Time cannot be before Start Time",
[End Time]=[Start Time], "End Time cannot be the same as Start Time",
not IsUserEmail("david@example.com") or not IsUserEmail("jason@example.com") and
([Date]>[Test Date] or [Date]<[Test Date]-Days(7)),"Date must be in current work week")

What am I missing? Probably just a set of () somewhere. But I can't figure it out. Any suggestions?

Thank you!

------------------------------
David
------------------------------
  • UrsulaLlaveria's avatar
    UrsulaLlaveria
    Qrew Assistant Captain
    hmmm, I am wondering if it has to do with the lack of IF in front of the not IsUserEmail. 

    Maybe it should look more something like...

    If([End Time]<[Start Time], "End Time cannot be before Start Time",
    //else if 
    if([End Time]=[Start Time], "End Time cannot be the same as Start Time",
    //else
    ////separate out both statements with parenthesis
    if(((not IsUserEmail("david@example.com")) OR (not IsUserEmail("jason@example.com"))) 
    AND 
    ([Date]>[Test Date] OR [Date]<[Test Date]-Days(7)),"Date must be in current work week")))
    //the final parenthesis close all three if statements. 
    including all of these if statements is not necessary, but may make it easier to see where you are getting hung up. 

    I do want to note, I would make this a formula text field at the table level, add it to the form, and based on the response, a form rule should prevent you from saving, instead of a Custom Data Rule. That way this field can be used on reports as well as other formula fields. 
     
    thanks

    ------------------------------
    Ursula
    ------------------------------