Skip to main content
Question

Expense receipt customisation problem

  • April 10, 2026
  • 0 replies
  • 8 views

Forum|alt.badge.img+1

Hi, I'm currently working on a customization in Acumatica and ran into a tricky issue involving workflow timing and an external AI call. Here’s the situation:

Code Summary

Context: Acumatica ERP, page EP301020 (Expense Claim Details), C# .NET Framework 4.8.

What the code does

A custom button "SubmitWithAI" replaces the standard submit and performs two things:

  1. Synchronous (blocking) validations:

  • Photo is required

  • Project and task are required

  • Item is excluded

  • Bank Feed amount must match the receipt amount

  1. AI analysis (call to GPT-4o via OpenAI API):

  • Sends receipt images in base64

  • GPT analyzes and returns a JSON with amount, taxes, tip, category, currency, etc.

  • The GPT JSON is compared with Acumatica data

  • The result is saved in two custom fields (UsrAnalyseAI, UsrReponseIA)

It works, but…

The problem

Symptom
The GPT call takes 5–25 seconds — the user is blocked waiting the entire time before the submit completes.

Core issue
The core issue is that the workflow evaluates conditions before the AI result is persisted.

What we tried

Override of Submit
At the start of the approval, it seems the system takes the data at the moment the submit button is clicked, and not after receiving the ChatGPT response (UsrAnalyseAI, UsrReponseIA).

Tested PXLongOperation.StartOperation
This made performance worse and triggered different execution paths in the code.

Tried adding an additional step in the workflow engine
But this broke the approval process.
It created “corrupted” states because the workflow does not seem to have full control:

  • RemoveHold sets IsHold = false

  • The approval engine appears to run in the background independently, instead of aligning with the “Pending Approval” state

What we are looking for

A way to execute code after the save but before the workflow condition evaluation in Acumatica,
or an alternative architecture that avoids user waiting time without breaking workflow logic.

r/acumaticaerp - Expense receipt customisation problem