How to get more specific error details from getErrorDetail() ?
- 8 months ago
Use case is the following. I have an import feature for our custom Conflict Mineral Solution. Basically I read the data from the source document and add new items.
I use the proven concept from the end of this blog: https://aras.com/en/blog/aras-best-practices-server-side-code. Instead of doing multiple applies I execute one large AML query to add all the data.
Technically the use case is comparable to the mass import of Manufacturer Parts. Import only works if the "Manufacturer" exists in the database. If one Manufacturer is missing, the whole query will fail. But we cannot easy tell, which Manufacturer was missing. But I discovered that in my use case the missing Manufacturer/Smelter is Part of getErrorDetail().
The idea was to catch the Smelter number from getErrorDetail and open up a new Form so can add the missing smelter. That was the reason for the title of this post.
I want to avoid to use add/merge to add the missing data automatically. Conflict Mineral data is standardized, but companies show great creativity in not following the standard AT ALL. There is certain data that you just don´t want to automatically add to your db.
But I think I found a solution while writing this answer.
I was probably too focused on the "do something AFTER the error occured" concept. Maybe I should prevent the error from the start.
I could do one "get" query first with many logic or´s to check if we already know all the listed Manufacturers. Than match the result with the data we want to import. If data is missing, offer the user the option to add the missing elements before trying the actual import.
This should do the job. But I am open to even better ideas :).