AIF-service call with COM and .Net Business Connector
When executing an AIF-service with the COM and .Net Business Connector the client will not be notified about exceptions during the execution. The reason for this is, that AIF-services are always executed within a transaction (ttslevel = 1) even when no ttsBegin has been executed. And as described on the X++ blog, exceptions are not caught within the transaction (sample is taken from the X++ blog):
1: try
2: {
3: MyTableType t;
4: ttsBegin; // Start a transaction
5: try
6: {
7: throw error(“Something bad happened”);
8: }
9: catch
10: {
11: // Innermost catch block
12: }
13: update_recordset t … // Must run within a transaction
14: ttsCommit; // Commit the transaction
15: }
16: catch
17: {
18: Info (“In outermost exception handler”);
19: }
20:
The exception thrown in line 7 would be caught in line 16.
If you need to handle the exceptions on the client-side, you can create a workaround by calling a ttsAbort before executing the AIF-service code. The best way to implement this workaround is to create a new AIF-service that executes the ttsAbort before calling the original AIF-service code. In that case the original AIF-service can stay “as is”.