Hi,
I ran into a problem with error handling in data input forms/dialogs. Maybe you have an idea how this can be solved:
I have two tables, "Customer" and "Contact", where Customer has FK field "ContactId" linked to a Contact record.
I have created a page with customers and an auto-generated "Add" button (+ dialog) to add new customers. Since Radzen does not know that a new Contact also needs to be created for a new customer, I did the following:
1.) In the onLoad of the "Add" dialog, I created and assign a new property called "contact" with a new contact object and in the code where the new Customer object is created, I assign the Contact property of the new Customer to the newly created Contact.
2.) In the "New Customer" form, I removed the dropdown box for selecting the contact (which does not make sense any more!). Instead, I added the new fields for the contact record (like Customer.Contact.Adress, etc.).
This works well so that when I click on "Add" customer, the form appears where I can enter all the fields for the customer AND the newly created & linked contact record for this customer. When I hit "Save", the new customer record and the new contact record are created and both are linked by the FK as expected.
Now, here is my problem: There are some fields in the contact record, that are mandatory. If I forget to enter them, the INSERT operation fails, because the DB does not allow these fields to be null. As a result the Balzor app gets inoperable and I cannot close the dialog or click Cancel any more.
In the submit event for the form, it says "Invoke CreateCustomer" and then "Close Dialog" and there is also an Error branch where it says "Notify".
My problem is, that the insert error does not cause the notification to appear. Instead the app gets inoperable. What needs to be done to corectly handle this INSERT error caused by the failed INSERT into "Contact" due to a required value?
Any help would be appreciated!
Best regards,
Joe