Scope: managed applications.
Best practices
In some cases, you might need to inform users that the data entry is invalid or impossible until some required fields are filled in. To do so, employ the following approach.
-
To set up the warning, use the WarningOnEditRepresentation and WarningOnEdit properties.
-
Select the field in Designer and specify the warning text in the WarningOnEdit property.
-
Change the value of WarningOnEditRepresentation programmatically when the field is activated and the conditions change.
-
Grant users the right to edit table entries, including the ones that don't meet the conditions.
Example. The Costs form has a table with the CostItem and CostItemDimension fields. To fill in the CostItemDimension field, users have to specify CostItem first. The code sample for this use case:
&AtClient Procedure SetWarningOnEdit() If NOT ValueIsFilled(Items.Costs.CurrentData.CostItem) Then If NOT ValueIsFilled(Items.Costs.CurrentData.CostItemDimension) Then Items.CostsCostItemDimension.WarningOnEditRepresentation = WarningOnEditRepresentation.Show; Else Items.CostsCostItemDimension.WarningOnEditRepresentation= WarningOnEditRepresentation.DontShow; EndIf; Else Items.CostsCostItemDimension.WarningOnEditRepresentation= WarningOnEditRepresentation.DontShow; EndIf; EndProcedure
&AtClient Procedure CostsOnActivateRow(Item) SetWarningOnEdit(); EndProcedure
&AtClient Procedure CostsCostItemOnEdit(Item) SetWarningOnEdit() EndProcedure
&AtClient Procedure CostsCostItemDimensionOnEdit(Item) SetWarningOnEdit() EndProcedure
If the warning text is also conditional, change the value of WarningOnEdit programmatically.
|