Hello everyone,
I've got an issue whereby I want to put 1 field in my form to be mandatory, and if it is empty, it will throw error. So this is the class looks like ->
class CustTableForm_MyField_OnModified
{
[FormDataFieldEventHandler(formDataFieldStr(CustTable, CustTable, MyField), FormDataFieldEventType::Modified)]
public static void MyField_OnModified(FormDataObject sender, FormDataFieldEventArgs e)
{
FormDataSource custTable_ds = sender.datasource();
CustTable custTable = custTable_ds.cursor();
if (CustTable.Group == "Group1" && CustTable.MyField == NoYes::Yes)
{
custTable_ds.object(fieldNum(CustTable, MyField2)).mandatory(true);
custTable_ds.object(fieldNum(CustTable, MyField3)).setValue("Sample1");
}
else
{
custTable_ds.object(fieldNum(CustTable, MyField2)).mandatory(false);
custTable_ds.object(fieldNum(CustTable, MyField3)).setValue("Sample2");
}
custTable_ds.refresh();
}
}
When I hit Save on my form, while it is empty for Field2, it will show error "Field2 must be filled in" twice. The question is why two times ? Also actually how is the behaviour of this event handler ? because when it is error like that, I cannot even "Esc", it will still in this form until it is satisfied.
For the double message, at first I thought is because the Refresh datasource at below it. it turns out no after I remarks it, the message will still appeared twice.
Please advice,
Thanks