Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested answer

How To Mark Customer Invoice in (Free Text Invoices > Settle Open Transaction) Based on Invoice Number Using x++?

(0) ShareShare
ReportReport
Posted on by 981

Hello dear experts,

How to mark a customer invoice in (Free Text Invoices > Settle open transactions) based on an invoice id?

If I have the invoice id number of an invoice that is available in the (Settle open transactions) screen, how can I mark it in x++?

While looking and searching, I found that I have to use "CustVendOpenTransManager" class.

But i'm not sure how to construct the class based on the invoice id and customer id.

any advice is appreciated!

Thanks in advance!

  • Suggested answer
    Sukrut Parab Profile Picture
    71,687 Moderator on at
    RE: How To Mark Customer Invoice in (Free Text Invoices > Settle Open Transaction) Based on Invoice Number Using x++?

    HI MoMochi ,

    It was marked to customer payment journal because you might have copied code pasted by Andre  where CustVendOpenTransManager is getting instantiated from ledgerjournaltrans.

    With above code , the open transaction is going to be marked against customer record. If you would like to  mark it against free text invoice use custInvoiceTable  , select the open transaction and then use updateTransMarked method to mark it .

    your CustVendOpenTransManager  initilization should  be like this  -

    CustVendOpenTransManager manager = CustVendOpenTransManager::construct(custInvoiceTable );

  • Momochi Profile Picture
    981 on at
    RE: How To Mark Customer Invoice in (Free Text Invoices > Settle Open Transaction) Based on Invoice Number Using x++?

    Hi Sukrat,

    Yes, when I went to Inquiry > Specification it was linked to a customer payment journal.

    While I wanted it to be linked to a free text invoice.

    I'm doing the code on a custom field in the free text invoice screen "CustFreeInvoice Form" where the user can select the open invoices using a look-up.

    and "onModified" event I'm typed this code:

    CustTransOpen   _custTransOpenInvoice, _custTransOpen;
    CustInvoiceTable _custInvoiceTable = sender.formRun().dataSource(formDataSourceStr(CustFreeInvoice,CustInvoiceTable)).cursor();
    CustTable custTable = CustTable::find(_custInvoiceTable.OrderAccount);
    CustVendOpenTransManager manager = CustVendOpenTransManager::construct(custTable);
    CustTrans custTrans = CustTrans::findFromInvoice(_openInvoiceId, _custInvoiceTable.OrderAccount);
    
    _custTransOpenInvoice = CustTransOpen::findRefId(custTrans.RecId);
    if (!manager.getTransMarkedByOtherSpec(_custTransOpenInvoice))
    {
        manager.updateTransMarked(_custTransOpenInvoice, NoYes::Yes);
    }

    Please advise me on where I'm doing wrong in the initializations.

    Thanks!

  • Sukrut Parab Profile Picture
    71,687 Moderator on at
    RE: How To Mark Customer Invoice in (Free Text Invoices > Settle Open Transaction) Based on Invoice Number Using x++?

    That symbol means the transaction is mark for settlement but with some other record .  If you select the correct origin record (e.g sales order or Customer ) against which you are marking transaction for settlement , system will show mark check box as YES.

    If you are on settle transctions screen use Inquiry > specifications button to see against which origin transaction is it marked to . If it is marked to some other order than what you want , then you are doing something wrong in your code .

  • Momochi Profile Picture
    981 on at
    RE: How To Mark Customer Invoice in (Free Text Invoices > Settle Open Transaction) Based on Invoice Number Using x++?

    Hello dear Suktrat,

    I really appreciate your detailed help!

    But as I mentioned in my previous reply to Andre, what I got using the "manager.updateTransMarked(CustTransOpenInvoice, NoYes::Yes)" is highlighted in yellow in the next screenshot:

    pastedimage1625685557711v1.png

    What I needed was to check the checkbox.

    is it possible?

    Thanks!

  • Momochi Profile Picture
    981 on at
    RE: How To Mark Customer Invoice in (Free Text Invoices > Settle Open Transaction) Based on Invoice Number Using x++?

    Thank you dear Andre for the help,

    When I used this method "manager.updateTransMarked(custTransOpen, NoYes::Yes)", here what happened to the open invoice highlighted in yellow:

    pastedimage1625685222200v1.png

    What I needed to do was to mark on the checkbox.

    Am I doing it wrong?

    I tried looking for other methods inside the CustVendOpenTransManager class but no luck.

    Please advise if it's possible to check the checkbox.

    Thanks again!

  • Suggested answer
    Sukrut Parab Profile Picture
    71,687 Moderator on at
    RE: How To Mark Customer Invoice in (Free Text Invoices > Settle Open Transaction) Based on Invoice Number Using x++?

    You can use SpecTransManager  class for it. It has to be initialize from the originator record , in your scenario its free text invoice . See below code for initialize part

     SpecTransManager writeOffSpecTransManager = SpecTransManager::newFromSpec(_ledgerJournalTrans);

    Once you initialize spectrans manager  find the Open transaction  (CustTransOpen) and use insert method to  mark the transaction against originating transaction for example , Sales order , customer , free text invoice etc. 

     specTransManager.insert(
                            custtransopenOrigPaym.company(),
                            custtransopenOrigPaym.TableId,
                            custtransopenOrigPaym.RecId,
                            custtransopenOrigPaym.AmountCur,
                            custtransopenOrigPaym.custTrans().CurrencyCode);

    You can use CustVendOpenTransManager class as well for settlement of two transactions with each other . For example , If you would like to settle invoice and payment for a specific customer together  , You can initialize it like below 

     CustVendOpenTransManager manager = CustVendOpenTransManager::construct(custTable);
     
     //Select open tranasction for invoice , You can find it as per your requirement 
     
       custTransOpenInvoice = CustTransOpen::find(markedCustTransOpen.RecId);
        custTransopenPayment = CustTransOpen::findRefId(custTransrefund.RecId);
       
       //mark payment and Invoice for settlement
       manager.updateTransMarked(custTransOpenInvoice,NoYes::Yes);
       manager.updateTransMarked(custTransopenPayment,NoYes::Yes);
       manager.updateSpecTransWithSelectedDate();
       manager.settleMarkedTrans();

  • Suggested answer
    André Arnaud de Calavon Profile Picture
    294,765 Super User 2025 Season 1 on at
    RE: How To Mark Customer Invoice in (Free Text Invoices > Settle Open Transaction) Based on Invoice Number Using x++?

    Hi Momochi,

    You can use the metadata search option in Visual Studio to find some examples. E.g. the class RetailEODStatementPaymentJournal has an example:

            CustVendOpenTransManager manager;
            CustTransOpen custTransOpen;
            ;
    
            custTransOpen = this.getCustTransOpen(_ledgerJournalTrans.MarkedInvoice, _ledgerJournalTrans.parmAccount());
    
            if (custTransOpen)
            {
                // mark/unmark this invoice's open customer transaction
                //  for settlement against the ledger journal payment line
                manager = CustVendOpenTransManager::construct(_ledgerJournalTrans);
                if (!manager.getTransMarkedByOtherSpec(custTransOpen))
                {
                    manager.updateTransMarked(custTransOpen, _shouldMark);
                }
            }
    

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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Kudos to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 318 Most Valuable Professional

#2
Abhilash Warrier Profile Picture

Abhilash Warrier 273

#3
Jonas "Jones" Melgaard Profile Picture

Jonas "Jones" Melgaard 181 Super User 2025 Season 1

Overall leaderboard

Product updates

Dynamics 365 release plans