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 free text invoice by code

(0) ShareShare
ReportReport
Posted on by

Hello,

I have to create new button that will call a RunBase class that will create a Free text invoice. I have list page with records. This button will allow multi select of different records but will be grouped per customer. This means if the user selects 3 records for which 2 of them belong to customer 001 and 1 belong to customer 003 than the function should create 2 different free text invoices. The class should show dialog with Invoice date and Post parameters.

The question is how to create this. I know i must populate this 2 tables:

a. CustInvoiceTable
b. CustInvoiceLine

what i need to write in mu run method and what in my main method???

*This post is locked for comments

I have the same question (0)
  • Sohaib Cheema Profile Picture
    49,438 User Group Leader on at

    you can group current records using query or whatever way. Then you can keep this information which is grouped by customer-id into a temp table. You can give this temp table to your class method and your class method can act on that temp data. you can find on search engine how to create free text invoice in x++. if you fail to find this, on search engine, tell us, so we can do it for you or we can provide you code to create free text invoice.

  • Community Member Profile Picture
    on at

    I cant insert new Line

  • Verified answer
    Sohaib Cheema Profile Picture
    49,438 User Group Leader on at

    1) you are not passing reference of Header in lines, while creating line. That makes your lines orphan, as they don't belong to any header. You can pass header reference in lines by following code

    CustInvoiceLine.ParentRecId  = custInvoiceTable.RecId

    2) group your data by taking selected lines into new buffer, if you will group in same data source, it will effect current form query. You can loop over all selected lines and throw those into a temp table. then ready data using groupby from temp table  

  • Community Member Profile Picture
    on at

    ok thank you for the first. It now works.

    But for the second can you send me some code how to do it? I can't find anything similar and i have no idea how to do grouping and how to use temp table.

  • Verified answer
    Sohaib Cheema Profile Picture
    49,438 User Group Leader on at

    Do you know how to loop through selected records? You may, have a look at next post

    You can also make use of MultiSelectionHelper     

     

    Get selected records and insert those into temp table. Inserting a record in temp table is almost same as doing for regular table.    You may, have a look at next URL.

     

    Next when your TmpTable is ready, send it to class and let your Class work on it. Grouping data, which you collected in temp table, is same, as you do grouping in select statement.

  • Community Member Profile Picture
    on at

    I have created temp table and fill it with records. But when i do this

    while select * from axmTempTable

           group by axmTempTable.CustAccount

           where axmTempTable.IsPayed == NoYes::No

       {

       ttsBegin;

           custInvoiceTable.OrderAccount = axmTempTable.CustAccount;

           custInvoiceTable.InvoiceAccount = axmTempTable.CustAccount;

           custInvoiceTable.InvoiceDate = invoiceDate;

           custInvoiceTable.CurrencyCode = custTable.Currency;

           custInvoiceTable.insert();

       ttsCommit;

    }

    gives me  empty buffer and i can't use selected records . Why i can't use data from temp table. What is the problem? How i can solve this???

  • Suggested answer
    Community Member Profile Picture
    on at

    Hy EmiliJaN

    I had created a job to create free text invoice through code in x++ ax 2012. Following is the code

    static void CreateFreeTextInvoice(Args _args)
    {
    CustInvoiceTable custInvoiceTable;

    custInvoiceTable.OrderAccount ="DE-001";
    custInvoiceTable.InvoiceAccount = "DE-001";
    custInvoiceTable.CurrencyCode = "USD";
    custInvoiceTable.InvoiceDate = systemDateGet();
    custInvoiceTable.insert();
    info ("Inserted");
    }

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