Uses OnGetVariableValue
to resolve a <var>VarID</var> placeholder that
does not correspond to any field of the active dataset.
The delete confirmation should name the order, the customer, and who is currently logged in - the first two are dataset fields, the third is not:
FGrid.DelRowQuestion := 'Delete order <var>OrderNo</var> for <var>CustomerName</var>'
+ ', confirmed by <var>CurrentUser</var>?';
procedure TfrmOrders.GridGetVariableValue(VarID: string; var Value: string);
begin
if SameText(VarID, 'CurrentUser') then
Value := Session.LoggedInUserName
else
Value := '?'; // unrecognized placeholder - keep it visible instead of blank
end;
OrderNo and CustomerName above resolve
directly from the current row’s fields and never reach this handler at
all - it only fires for CurrentUser, which
Table.FindField('CurrentUser') would not find.DelRowQuestion, DelRowsQuestion, and
DelRowCaption all resolve through the same handler -
VarID is the only way to tell which placeholder is being
asked for, there is no separate parameter identifying which string
property triggered it.OnGetVariableValue unassigned replaces an unresolved
<var> with an empty string rather than raising - the
else branch above ('?') is a deliberate choice
to make a typo in a placeholder name visible in the prompt instead of
silently vanishing.