can’t use @ThisName in Hide-When formulas, LOTUS NOTES meta coding FAIL

I had hoped to use the “@ThisName” to get the suffix of the field name “Comment_1” and hide it if the Field “Status_1” is “Pending” by doing this :

1
2
3
4
Suffix := @Right(@ThisName; "_");
EmpListFieldName := "Status_" + Suffix;
Status_value := @GetField(EmpListFieldName);
@If( Status_value    = "Pending";@Return(@True);@Return(@False));

but it didn’t work 🙁

finally traced it down to the “@ThisName” formula and the Help doc’s confirmed the bad news about the @ThisName formula:

Note A hide formula is not a field formula, even though it can be set from the field properties dialog. The hide formula applies to the paragraph containing the field. Since a paragraph can contain several fields, there is no “current field” in this context.

Instead, I will have to hard code the suffix reference, and replace the above code with:

1
2
3
4
Suffix :=  "1";
EmpListFieldName := "Status_" + Suffix;
Status_value := @GetField(EmpListFieldName);
@If( Status_value    = "Pending";@Return(@True);@Return(@False))

which can be compacted down to

1
@GetField("Status_" + "1") = "Pending"

and it will need to be modified for every one of a large number of fields!!! (hence my wish to meta code).

I’ve add a “change this please on idea jam

see Ben Langhinrichs on Writing better hide-when formulas for more.

Updates : This post was linked to from DominoPower Can’t use @ThisName in Hide-When formulas on Friday, September 11, 2009, from their News Center. cool!

Richard Schwartz made a useful comment on the ideaJam posting which is under appreciated, and quickly forgotten, that:

“Hide-whens are bound to paragraph, not to a field.”

which was very helpful in me understanding why it’s “working a designed” and not broken, even if mildly frustrating!

2 Replies to “can’t use @ThisName in Hide-When formulas, LOTUS NOTES meta coding FAIL”

  1. Workaround: add a hidden computed field called hide_1. Set the field formula to what you wanted to use for the hide formula. In the hide formula for the paragraph(s) containing the status_1 and comments_1 fields, enter “hide_1” as the hide-when formula. Repeat as needed for _2, _3, etc.

    I’m afraid that there’s no way they can change it. Would break backward compatibility in a big way for any app in which the field is not the only thing in the paragraph.

Leave a Reply