ALAppExtensions icon indicating copy to clipboard operation
ALAppExtensions copied to clipboard

OnCustomProcessing in CU1380, Batch Processing Mgt.

Open renebrummel opened this issue 8 years ago • 3 comments

In CU1380, Batch Processing Mgt. MS has created a great new event called OnCustomProcessing with a handled parameter.

My issue is that MS has used this event themselves in CU1371, Sales Batch Post Mgt. Rendering the event nearly completely useless since we cannot predict which subscription will be executed first and all events might set or reset the handled parameter in a different way.

I would like to propose MS either moves their code in function HandleOnCustomProcessing to a hook instead of an event subscriber or create a new event before the OnCustomProcessing event in CU1380.

Similar issues exist with the events OnVerifyRecord and OnBeforeBatchProcessing in CU1380.

renebrummel avatar Mar 15 '18 08:03 renebrummel

Hi,

I will pass your feedback on the relevant team.

A few comments:

  • whether MS uses events or not should not matter. Any extension could do the same and you would know even less about what is going on (you can't see their code at all). When using events you have to design for multiple subscribers and make sure your code runs properly regardless of order or what others do. The handled pattern has the problem that when used properly, only the first subscriber gets to execute but no-one knows what that is. If used improperly, multiple subscribers will run their code and the results may be unpredictable or result in error (like try and post the same doc twice using different codeunits?)
  • In this particular case, if you don't want the MS subscriber to handle the processing of SalesHeaders you can turn off "Post with Job Queue" in Sales & Receivables Setup. You'll then be able to handle this yourself.

br/Gert

grobyns avatar Aug 03 '18 12:08 grobyns

Hi @renebrummel,

You mentioned three events of COD1380 that are considered to be "internal". If you say you want to subscribe to these events, where COD1371 or COD1372 are manually bind to, then you trying to get into the internals of the mechanism supporting this whole functionality. In order to help you we need more details about a scenario you want to implement. The options will be:

  • we add events to COD1371/1372 so you can customize sales/purchase posting.
  • we suggest you to create a new codeunit similar to COD1371/1372 where you implement you very special handling.

Best regards, Stan.

StanPesotskiy avatar Aug 23 '18 14:08 StanPesotskiy

This issue seems to have been resolved. Closing issue.

JesperSchulz avatar Nov 02 '18 08:11 JesperSchulz