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)

SalesFormLetter parmId question

(0) ShareShare
ReportReport
Posted on by 427

Greetings,

I've written some custom code to create invoices for a specific situation. I'm using the code pasted below. I've noticed that the SalesParmUpdate record is reused and the related SalesParmTable rows are changed whenever my customization is executed. It does not seem to be the case with what SalesEditLines perform, as the parmId is always incremented. I haven't seen any "closing" method which must be done after SalesFormLetter.run() or clean-up process.

So basically, if anyone knows, am I missing some lines which prevent parmId to be reused or is it meaningless and can be disregarded?

private void createInvoice(Query _query, TransDate _invoiceDate, SalesUpdate _salesUpdate)

{
SalesFormLetter salesFormLetter;
QueryRun queryRun;
ParmId parmId;

queryRun = new QueryRun(_query);
salesFormLetter = SalesFormLetter::construct(DocumentStatus::Invoice);
salesFormLetter.specQty(_salesUpdate);
salesFormLetter.chooseLinesQuery(queryRun);
salesFormLetter.transDate(_invoiceDate);
salesFormLetter.printFormLetter(false);
salesFormLetter.chooseLines();
salesFormLetter.SumBy(AccountOrder::Account);
salesFormLetter.reArrange(false);
parmId = salesFormLetter.parmId();
salesFormLetter.run();
}

AX 2012 cu3 release 8

Regards,

Eric

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Arkadia2 Profile Picture
    427 on at

    Greetings,

    Instead of using SalesFormLetter, I create a SalesFormLetter_invoice object directly and force LoadFromSysLastValue to false. Default behaviour from SalesFormLetter is set to true. So far it seems to be holding up. I'll check, I may have a few useless initXXXX() lines, but it looks like this if anyone runs into a similar situation:

    private void createInvoice(Query _query, TransDate _invoiceDate, SalesUpdate _salesUpdate)

    {

       SalesFormLetter_invoice letter = new salesFormLetter_invoice();

       QueryRun queryRun = new queryRun(_query);

       letter.initParmDefault();

       letter.parmLoadFromSysLastValue(false);

       letter.init();

       letter.specQty(_salesUpdate);

       letter.chooseLinesQuery(queryRun);

       letter.transDate(_invoiceDate);

       letter.printFormLetter(false);

       letter.chooseLines();

       letter.SumBy(AccountOrder::Account);

       letter.reArrangeNow(true);

       letter.reArrange(false);

       letter.run();

    }

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