Update GL Account on AP Invoice Lines in Function

Hi there everyone,

I’ve been working on getting AP Invoices created via a code function. I have tried many things and can get everything properly populated except the GL Account under the GL Analysis section of the AP Invoice Line. It automatically lands in the suspense account, which we can manually change via the UI if absolutely necessary. But, has anyone had any luck with updating the GL Account in a custom code function? This would make things a lot easier on our AP team.

Thanks!

What I’ve Tried So Far:

  • GL Control Setup: I verified that the relevant GL Controls are set up correctly. If I manually create this transaction in the UI, the GL account populates just fine, confirming that the GL Controls and Posting Rules are valid for this context.
  • Tracing: I ran a trace on the manual process to see which methods are called. I am calling GetNew... and GetDefault... in my code, but the GL account field returns empty. The trace wasn’t very helpful, not sure if it just can’t trace server side execution or if I might be doing the trace wrong.
  • ChangeRow Method: I attempted to force the logic by calling various Change methods after setting the initial data, hoping it would trigger the re-calculation of the GL, but it had no effect.
  • RowMod: I attempted setting the RowMod to “A” (Added) or “U” (Updated) before calling the master update methods.
  • BPMs: I made sure there weren’t other Data Directives/Method Directives enabled that might interfere.

My Question: Is there a specific method that I need to invoke when working via BPM/Function to get the GL Account to stick? I tried to do something similar to what @carlosqt mentioned in the screenshot below, but could get none of those runs to work properly, they were leaving amounts off the invoice and it was still landing in suspense. I’m out of ideas. It seems like no matter what it is either overwriting whatever GL I pass in with suspense or the account doesn’t stick and it defaults to suspense.

This is 2025.1 I’m in by the way. As always, any reply is appreciated :slightly_smiling_face: