Why Prompt Table Edit does not get triggered when a value is changed through PeopleCode?
When a record table has a default value set at FieldDefault event, neither the FieldEdit event nor the FieldChange event gets triggered and the validations and fieldchange code written does not get triggered. WHY?
The general behavior of a record field having ‘Prompt Table Edit’ enabled, is to edit any value entered by the user against its prompt table and issue an error message in case the user entered value does not match the list of values in the prompt table.
However, if a value is entered to the prompt field through peoplecode in Field Default event, this validation would not happen. As a result, any invalid value assigned to the prompt field value in FieldDefault event through peoplecode gets saved by-passing the validation.
This happens because a FieldDefault event on a new row of data does not trigger FieldEdit and FieldChange events due to Performance reasons. So, the Invalid Value message from the prompt table edit check will not happen when an invalid value is entered through peoplecode however, when the user types an invalid value the FieldEdit and FieldChange events get triggered and the Invalid Value message gets displayed.
So it is left to the programmer to assign right values to the prompt field in FieldDefault. One better approach is to make use of the ExecuteEdits() method and the IsEditError property to make sure only right values are assigned to the record field with Prompt Edit.
Sample Code:
&RECORD.ExecuteEdits(%Edit_PromptTable);
If &RECORD.IsEditError Then
Error "Prompt Table Edit failure";
End-If;
If &RECORD.IsEditError Then
Error "Prompt Table Edit failure";
End-If;
I observed that the same would happen when you assign a value through FieldChange (Any PeopleCode event for that matter)
ReplyDeleteYes, that's right
Delete