Tinderbox User-to-User Forum (for formal tech support please email: info@eastgate.com)
http://www.eastgate.com/Tinderbox/forum//YaBB.cgi
Tinderbox Users >> Agent, Actions, Rules & Automation >> DisplayExpression with conditions
http://www.eastgate.com/Tinderbox/forum//YaBB.cgi?num=1404737143

Message started by John Doernberg on Jul 7th, 2014, 8:45am

Title: DisplayExpression with conditions
Post by John Doernberg on Jul 7th, 2014, 8:45am

In my daybook I have the DisplayExpression of my prototype set so that notes with dates display the date ($KeyDate) first then the name. I use "if ($KeyDate) {format($KeyDate, l)+( ")+$Name} else {$Name}." It works fine.

For notes requiring future action, I assign a future date to the date attribute $FollowUpDate. I want those notes to display the $FollowUpDate first instead of the $KeyDate, at least until I complete the follow up and change the $FollowUpDate back to "never." I had thought this would be as simple as essentially copying, pasting and adjusting the conditional described in the previous paragraph -- to "if ($FollowUpDate) {format($FollowUpDate, "l")+(" ")+$Name] else {format($KeyDate, "l")+(" ")+$Name}" (I'm not yet ambitious enough to add the additional conditional that the note should display $Name if there's neither a $FollowUpDate nor a $KeyDate). But the adjusted formula doesn't work: notes display just the $Name, with no date at all. What am I doing wrong?

Thanks.

Title: Re: DisplayExpression with conditions
Post by Mark Anderson on Jul 7th, 2014, 9:30am

Looks like a bracket error:

if ($FollowUpDate) {format($FollowUpDate, "l")+("      ")+$Name] else {format($KeyDate, "l")+("     ")+$Name}

You've used a square closing bracket ] (in red above) where you need a curly closing bracket }.

Note also a newer and more flexible way to use the format() command is the .format() operator. Thus whilst both have the same output, code like format($KeyDate, "l") may more often be seen written as $KeyDate.format( "l").

Title: Re: DisplayExpression with conditions
Post by John Doernberg on Jul 7th, 2014, 12:17pm

Thank you -- the eyesight goes first. It has also been a mystery to me whether the letter in quotation marks is a capital I, a lowercase L, or a number 1. I had expected it to be a lowercase L based on the Date format explanations that I saw, but apparently it's a capital I?

Is it easy to add an additional condition: that if there's neither a $FollowUpDate nor a $KeyDate, then only the $Name should be displayed? Right now notes with neither of those dates (e.g., the prototypes) display "never" then the name of the note. It would be nice to get rid of that "never."

Thanks as always.

Title: Re: DisplayExpression with conditions
Post by Mark Anderson on Jul 7th, 2014, 1:58pm

The format is a lowercase L, i.e. 'l'. The problem is fonts are inconsistent how the differentiate lowercase L, uppercase I, and the numeral 1. If in doubt, re-type the character with your own keyboard so it's the one you want even if the font makes it looks like something else. Date formats.

I'll take a look at the other question later - just heading out.

Title: Re: DisplayExpression with conditions
Post by Mark Anderson on Jul 7th, 2014, 3:48pm

For such a complex set of conditions, don't do the work in $DisplayExpression. Instead, use a rule to set a user String attribute and use the latter's value as the display expression. So here is the rule, which needs an extra string attribute 'MyString':

if($FollowUpDate!="never"){
$MyString=$FollowUpDate.format("l")+("       ")+$Name;
$Color="bright blue";
} else {
if($KeyDate!="never"){
     $MyString=$KeyDate.format("l")+("       ")+$Name;
     $Color="bright red";
} else {
     $MyString=$Name;
     $Color=;
};
};


The display expression is now just this:

$MyString

Edit: I left in some test code that changes $Color so as to more easily check for changes, remove that if you don't need it.

Tinderbox User-to-User Forum (for formal tech support please email: info@eastgate.com) » Powered by YaBB 2.2.1!
YaBB © 2000-2008. All Rights Reserved.