Hi everyone,
We are trying to automate General Journal Posting (cash receipt journal) but are having issues with error handling.
We would like to handle scenarios where one or more document numbers in the journal cannot post because of an error but we would like to continue posting the other lines.
This is our scenario:
- We have 2 custom tables called PaymentGroup and Payments Lines (one PaymentGroup can have multiple Payment Lines)
- We extended the Gen Jnl Line with a new field called PaymentGroup ID
- For each Payments Line, we create a journal line. In the journal line we record the PaymentGroup ID
- The automation we're trying to build, loops the PaymentGroups -> finds the related journal lines and tries to post them.
We want an approach where all journal lines related to the same PaymentGroup should post successfully otherwise nothing should post for that PaymentGroup .
Example: PaymentGroup with ID = PG1 creates 3 Journal lines with document numbers: D1, D2, D3. PaymentGroup with ID = PG2 creates 3 Journal lines with document numbers: D4, D5, D6.
We are on purpose putting D2 out of balance to make it fail and we are ending up with D1 successfully posted and D2 and D3 not posted, still in the journal. In this case we are expecting that D1, D2 and D3 do not post while D4, D5, D6 post successfully.
We tried to use the Gen Jnl Post Batch with suppress commit set to true but still got the same result. We have also tried using the Gen Jnl Post codeunit. We have also tried to use preview posting to validate the lines before attempting to actually post but preview posting always throws an error.
Any help how this can be achieved?