For later readers, the problem wasn’t the prototype as such but that the rule code had been inserted accidentally in the wrong attribute (most likely when using the Action Inspector). The code is supposed to be a rule so goes in $Rule (the ‘Rule’ sub-tab in the Action Inspector), but had had been placed in $OnAdd (the ‘Action’ sub-tab in the Action Inspector).
The result is the code now only fires when a child note is add to the prototype or notes using the prototype.
As to the code, Tinderbox action code lacks an ‘else if’ operator. But it can be simulated by nesting the extra ‘if’ in the else branch of the initial ‘if’. The code also has unclosed branches (a missing }. So I think your intended rule code is this:
$PendingFor = days($DateSent, date("today"));
if($Accepted==true){
$Color="yellow";
} else{
if($Requested==true){
$Color="red";
}
} else {
$Color="grey";
}
Note, before setting this (via the Inspector) un-tick the ‘Enabled’ box bottom left as you don’t want this code run by the prototype, but only note inheriting from the prototype.
Not setting up the latter shows a very large $Pending for, as both dates have not date. So, you want to set $PendingFor if there is a date set for $DateSent:
if($DateSent){
$PendingFor = days($DateSent, date("today"));
}
Also, the document’s default $Color value is named colour 7 (confusing naming!) which looks like but is discrete from named colour grey. However, I assume the aim is to reset $Color to document default value. The code for that is:
$Color=;
Putting this together, as $Rule [sic] code, you should use:
if($DateSent){
$PendingFor = days($DateSent, date("today"));
};
if($Accepted==true){
$Color="yellow";
} else{
if($Requested==true){
$Color="red";
} else {
$Color=;
};
};
Note: using semi-colons after the final }of an if(){} or if(){}else{} block is not required but also does no harm. But for the learner it can help you check your logic.
In the same way, the above rule can be written with no line breaks and still work. But, again for the learner, indenting the contents of the if branches can help one understand if the logic will work as written.
A last thought, from testing this. The colour scheme you are using has very muddy colours (the scheme is optimised for map view). I suggest using ‘bright red’ rather than ‘red’ for requested-but-unaccepted state.