Hello, fellow TBXers,
I am trying to create a daily activity log in Tinderbox. I created a container where I store notes describing daily achievements.
I also added a User date attribute called $CompletionDate. I would like to have $CompletionDate set to “today” unless I manually specified a date.
I tried the following Rule:
If(!$CompletionDate){$CompletionDate=today};
However, the date is set to “never” rather than “today.”
Anyway, your help is most welcome.
Thanks!
Mariano
mwra
(Mark Anderson)
December 21, 2017, 10:32am
2
Is the ‘If’ above a typo? Action code is case sensitive. If I change ‘If’ to ‘if’ your code works for me. Slightly better usage - so as to get into good habits and not get bitten in more complex code - is to use date() when setting dates, even when using date designators . Thus:
if(!$CompletionDate){$CompletionDate=date("today")};
Thank you very much @mwra , bloody autocorrect
It works! I did spend, nonetheless, several minutes scratching my head…
Thanks once more.
M
1 Like
andreas
(Andreas Grimm)
September 26, 2018, 1:20pm
4
@mwra For me this is not working since every minute the $CompletionDate gets updated e.g. it adds another minute to the date.
How can one stamp a CompletionDate that represents the minute of completion and then does not change anymore.
My Rule (!) looks like this:
if($Checked==true){$Badge=ok; $CompletionDate=date("today")} else {$Badge=calendar; $CompletionDate=never};
Can someone help on this?
Thanks
PaulWalters
(Paul Walters)
September 26, 2018, 1:31pm
5
If you want a one-time rule then modify your rule with $Rule=;
as follows:
if($Checked==true){$Badge=ok; $CompletionDate=date("today");$Rule=;} else {$Badge=calendar; $CompletionDate=never};
This will wipe out the rule as soon as it runs once.
If you are going to use this in a lot of notes, then maybe consider using an Edict or a low-frequency Agent?
mwra
(Mark Anderson)
September 26, 2018, 2:07pm
6
Or, change
To
$CompletionDate|=date("today");
See the logical OR operator . This code will run continuously but only set $CompletionDate once. That said, I think @PaulWalters answer above is probably as, if not more, practical.
andreas
(Andreas Grimm)
September 26, 2018, 2:16pm
7
Just to the point, Maestro @PaulWalters . It works perfectly well for me. Thank you!
andreas
(Andreas Grimm)
September 26, 2018, 2:17pm
8
Thank you @mwra . Works well, too. But just as you said, @PaulWalters ’ suggestion might be the way to go in this very setting.
1 Like