Searching Function for "due date" including colorization

45 views
Skip to first unread message

Dennis Bork

unread,
Apr 24, 2018, 5:43:23 AM4/24/18
to mementodatabase
Hey everybody,

I have a database where I keep "last checked" fields for some of my RC "toys" :)

It's easy to create an expression that calculates the next "check due" date; that would be just lastdate + n seconds.

BUT: Is there a way to a) check if some entry is "overdue" and b) even colorize the overdue status?

The field "next check" is set to displays as an entry status for my DB items. But that's it, no overdue colorization of course.

Has anybody a solution at hand or any great hint?

Cheers

Dennis Bork

unread,
Apr 24, 2018, 6:00:10 AM4/24/18
to mementodatabase
EDIT: For example, if I would be able to control the state of a radio button field using Java Script that would be great.

IF (check for LastCheckField + n Days is still in the future)
 
{ IsDueField.RadioButton set to "not due" }
ELSE

  { IsDueField.RadioButton set to "due now" }
 

I could easily set the "IsDue" entries to colorized text and set their field role as "status", then. But how to achieve the rest?

Bill Crews

unread,
Apr 24, 2018, 7:09:57 AM4/24/18
to Dennis Bork, mementodatabase
There are multiple ways to do this. The most direct would be to add a JavaScript field that returns a color for an entry and identify that field as the one to use for Entry Color.

So, add JavaScript field entryColor, set to Execute script real-time. Script...

var daysCheckAgain = 5;
var dateCheckAgain = field("dateLastChecked").getTime() + (daysCheckAgain*1000*3600*24);
if (Date.now() > dateCheckAgain)
   "#FF0000";

Now, press the checkmark to save the field and press the MAIN tab, then press Entry Color and choose your new field entryColor.

Dennis Bork

unread,
Apr 24, 2018, 7:38:27 AM4/24/18
to mementodatabase
Awesome, thanks! It's working. Do you have an idea how to, instead of colorizing the whole entry, just colorize the LastChecked field, or any other field...?

Dennis Bork

unread,
Apr 24, 2018, 7:53:27 AM4/24/18
to mementodatabase

Or, easier put: Is it possible to return a COLORIZED string that I can put as a status...?

Bill Crews

unread,
Apr 24, 2018, 8:09:32 AM4/24/18
to Dennis Bork, mementodatabase
In choice fields, each choice (item) can be set to a color, and the text can optionally be set to that color. In other field types, you can set the color of the field within its font settings. If you want to set an indication conditionally, probably the best way would be to set a choice field to a value that has the color you want.

Alternatively, you could define a red date field and a white date field and have the visibility of each of them be dependent upon a choice field you've set, so the one colored the way you want will be displayed. Making it conditional would entail a trigger script.

Try defining a radio buttons field Recheck with a red item called DUE and an uncolored item called Pending. Define an Opening the library trigger that goes through all entries, setting the Recheck fields as appropriate...

var daysCheckAgain = 5;
var entries = lib().entries();
for (ex in entries) {
   var ent = entries[ex];
   var dateCheckAgain = ent.field("dateLastChecked").getTime() + (daysCheckAgain*1000*3600*24);
   if (Date.now() > dateCheckAgain)
      ent.set("Recheck", "DUE");
   else
      ent.set("Recheck", "Pending");
   }

I'm not a big fan of such looping through things; it makes things run slowly and doesn't deliver the big bang I would want for doing all that.

You could maybe avoid the looping by just doing it entry-by-entry by doing a non-looping version of that trigger in an Opening the entry edit card trigger instead.

If you decide to use date fields dependent upon the choice field, just make one of the date fields the "master", and the trigger can copy the value to the other date field to keep them in sync. I'm not a big fan of this technique, either.

I think the entry color would work fine for me.
   

Reply all
Reply to author
Forward
0 new messages