0

Message - Improvement

Heres a thing...

As these days I work mainly from home - I have a reminder that if appropriate! sends and email to my team at the office when I log into Ninox. The script is set in the global script area and works reasonably okay.... I have it do an email because as yet global scripts won't cause a pop up message to be triggered and certainly it won't pop one up to another user.

So the idea behind the script is once I have logged into the database app, it goes and looks for any occurrence of a jobs promisedby date that is is due 2 days from today -  if it finds one it sends the email.  Which job it finds does not matter as long as it due in 2 days - the purpose is to alert my team that some promised jobs are due and we have a daybook view that is filtered to show all promised jobs..... and my team can ensure with the suppliers that the goods/production is on target for the due date. ..... all good so far and bobs your mothers brother etc .... 

The extra lines re weekday testing simply checks to cover testing over a weekend. ie Thursday will not check for Saturday but will look for the following Monday instead etc...

This is the script (as as said works fine!)

openTable("JobDockets", "Live Jobs");
let d := if weekday(today()) = 3 then today() + 4
    else
        if weekday(today()) = 4 then today() + 4 else today() + 2 end
    end;
if cnt(select JobDockets where DispatchBy = d and Promised = true) > 0 then
    sendEmail({
        from: "mel@sampleXXXX.co.uk",
        to: "sales@sampleXXXX.co.uk",
        subject: "Promised jobs are soon due for dispatch",
        text: "Promised",
        html: "Some promised jobs are due to be dispatched, Please check the promised daybook for any jobs due to be dispatched and confirm with works/suppliers that all is on target"
    })
end

So whats the problem.?

Nothing major, but as I hop in and out of several databases and also have a database for doing testing and development. Then on the days that the trigger will fire, it fires every time I go back in after previously exiting earlier. So that is not great and my staff think I'm constantly reminding them to check the daybook. Some days it can fire maybe 8-10 times.

So I can live with my team telling me off but ... Can anyone suggest better/smarter way I could achieve the same task.

As said I 'm at home and my team are some 15 miles away....

Mel 馃檪

 

Ps I have tried building a table that acts as an internal email which was populated by me going down the jobs and setting a flag to add it to a daybook as a reminder but this failed on the days I am tied up with other duties or even off site. Hence the above script was born and frankly does not require anyone to remember to tick a chase flag

8 replies

null
    • Ninox partner
    • RoSoft_Steven.1
    • 2 yrs ago
    • Reported - view

    You can use a flag "mail sent" ? Or a date field "send on"? If these would be true then don't send a mail...

    Steven.

    • John_Halls
    • 2 yrs ago
    • Reported - view

    Hi Mel

     

    As Stephen says, use a flag. I use a table that only has one record. The fields are then used as global variables, so add a date field which can be tested prior to sending your daily email, and updated one the email has been sent.

     

    Regards John

    • Mel_Charles
    • 2 yrs ago
    • Reported - view

    Hi Guys I do use a flag as well. as stated I have a daybook view dedicated to promised jobs.

    But like most things it relies on other users checking that view or even the flags!!

    In and ideal works I would prefer the flag to pop up message to specific (other) users. but one can't have this (yet?)

    • John_Halls
    • 2 yrs ago
    • Reported - view

    I was thinking this sort of thing in the Trigger after open:

    let a := first(select Global);
    if a.LastOpened < today() then
        "Send email Script Here";
        a.(LastOpened := today())
    end
    

    No user involvement needed.

      • Mconneen
      • 2 yrs ago
      • Reported - view

      John Halls
      That would work...   Question... do you have a use case where due dates (promised by) may change through out the jobs lifecycle?

      If yes.. then the approach to tag the job with an "email reminder sent" flag during the send email script execution would cover that use case.   Your LastOpened may not.

    • Mel_Charles
    • 2 yrs ago
    • Reported - view

    In my case the promised date can vary so I think I'll stick with my original script.

    Thanks 馃檪

    Mel

      • Mconneen
      • 2 yrs ago
      • Reported - view

      Mel Charles 
      If you don't want to get overly complicated.. and you don't want to "nag" the staff.. a simple "notification sent" flag on your job and where you find the date to be within range... check for a null notification flag... and flip it not null when sent works..

      Event tables work.. but sound overly complicated for this use case.

    • Mel_Charles
    • 2 yrs ago
    • Reported - view

    Mconneen - That sounds like a sensible enhancement !馃憤

    cheers

    Mel

Content aside

  • Status Answered
  • 2 yrs agoLast active
  • 8Replies
  • 194Views
  • 4 Following