web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Create new vendor invoice by X++ code using FormRun

(0) ShareShare
ReportReport
Posted on by

Hi everyone,

I am trying to create a new vendor invoice in creation mode using this code : 

PurchFormLetter_Invoice purch;
Args args;
FormRun run;


purch = PurchFormLetter::construct(DocumentStatus::Invoice);

purch.parmOpenMode(OpenMode::New);


args = new args(formStr("VendEditInvoice"));

args.caller(purch);

run = classFactory.formRunClass(args);

run.init();

run.run();

run.detach();

The form is not opening because there seems to be missing a parmId in the init() method of VendEditInvoice...

*This post is locked for comments

I have the same question (0)
  • André Arnaud de Calavon Profile Picture
    301,049 Super User 2025 Season 2 on at

    Hi,

    Can you elaborate on your question? Where did you place this code? Do you get an error message? If so, please share the error.

  • Community Member Profile Picture
    on at

    I placed this code in the Main method of the VendInvoiceHeaderWorkflow class, so when I submit an invoice, I would like that a new one pops automatically and do so as long as I submit an invoice. There are no error message, I just noticed by debugging that the parmId in VendEditInvoice is empty and it opens a form that looks like this :

    formInvoice.PNG 

    It looks like a mix between a vendor invoice and a listpage, which makes absolutely no sense.

  • André Arnaud de Calavon Profile Picture
    301,049 Super User 2025 Season 2 on at

    Hi,

    Please explain the business scenario. It seems you want to have a repeatable scenario. When someone finished entry of an invoice (by submitting to the workflow) it should start a new fresh invoice entry for the next invoice. Is this correct? Is this just because someone does not like to create a new record manually?

    Have you considered how many forms will be open at the end of the day if you open a new form again and again?

  • Community Member Profile Picture
    on at

    Yes, when somebody will submit an invoice, it will start a new invoice. We are going to close the caller before opening the new one, this is why I used the run.detach() line, so we can close the parent and always have only one invoice opened at once.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans