Announcement

Collapse
No announcement yet.

Check field when date/time field = now.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Check field when date/time field = now.

    Good Morning All.

    This should be pretty basic but I can't figure out a solution so hopefully you guys can help. I need to check a boolean field when a date and time field = now. I have to schedule cron to run every minute for this which uses the report feature. The report feature doesn't have a now option so I believe my only option is using an expression. Does anyone use a expression or know how to put one together that would allow for pulling a report when this field = now?


  • #2
    You can do that with formula:

    I will use your field "send to KDS" and a checkbox field, that will be checked, when in send to KDS there is now

    Code:
    ifThen(
    sendToKds == datetime\now(),
    entity\setAttribute('checkbox', true)
    );
    Try that and return here, if it does not work.
    Last edited by shalmaxb; 09-01-2021, 08:24 PM. Reason: correction of formula

    Comment


    • dimyy
      dimyy commented
      Editing a comment
      1. sendToKds == datetime\now()
      2. My recomendation is sendToKds < datetime\now() && !checkbox. Probability of executing cron task exactly in 00s is not 100%

    • dodom2
      dodom2 commented
      Editing a comment
      By doing this is there a way of specifying time zone? or does it use the users time zone or system time zone?

  • #3
    You can try to provide the timezone in the formula. I don`t know, if it will work, but in other datetime functions it works.

    If so, it would be like this, but I did not test it:


    Code:
    ifThen(
    sendToKds == datetime\now('America/New_York'),
    entity\setAttribute('checkbox', true)
    );

    Comment


    • #4
      Timezone does work in formula, I recently came across this issue (see Feature request).

      As for the other coding above, I'm not too familiar with.

      Comment

      Working...
      X