Skip to main content

Mark Customer Transaction from X++ in AX2012

Use below code to mark customers open transaction from X++.



static void MarkOpenTransaction()
{
    custInvoiceJour custInvoiceJour;
    SalesTable  salesTable;
    specTrans   specTrans;
    custTrans   custTrans;
    custTransOpen   custTransOpen;
    TaxWithholdTrans    taxWithHoldTrans;
    TaxWithhold_CustPaym taxWithhold;
    CustVendOpenTransManager manager;
    ExchangeRateHelper  exch;
    AmountCur   totalSettleAmount;
    ;
    select firstOnly custInvoiceJour where custInvoiceJour.InvoiceId == '004452';// && _custInvoiceJour.SalesId == xml_SalesID.text();

    if(custInvoiceJour)
    {
        ttsBegin;
        salesTable = salesTable::find('000330');
        specTrans.SpecRecId = salesTable.RecId;

        select * from custTrans where custTrans.AccountNum == '000001' && custTrans.Invoice == custInvoiceJour.InvoiceId;

        select RecId, dataAreaId from custTransOpen where custTransOpen.RefRecId == custTrans.RecId;
        specTrans.RefRecId = custTransOpen.RecId;
        specTrans.RefTableId = tablename2id('CustTransOpen');

        specTrans.SpecTableId = salesTable.TableId;
        specTrans.Balance01 = str2num('-300');//amount
        specTrans.LineNum = 2;
        specTrans.Code = salesTable.CurrencyCode;
        specTrans.SpecCompany = salesTable.dataAreaId;
        specTrans.RefCompany = custTransOpen.dataAreaId;

        specTrans.insert();

        ttsCommit;
       
    }
}


thanks
p.

Comments

Popular posts from this blog

AX 7 - Get record marked and record selected on grid control in X++

Marked Records In AX, we often face a situation where we need to get the reference of those records which are marked on grid control. Using below code you can get those marked records in X++. Records marked can be seen in screenshot on the left. Array markedRecords = gridControl_DS.recordsMarked(); var lastMarkedRecord = markedRecords.lastIndex(); You will get a recId of last marked record in lastMarkedRecord. Using recordMarked() method of grid control data source, you can get an array of marked records which can be used for further iteration based on requirement. Selected Records At the same time, there is another operation called as Selected Records. When a grid control loads, a default first record is selected from the grid. To iterate through selected records, use below code. for (inv = gridControl_ds.getFirst(true) ? gridControl_ds.getFirst(true) : gridControl_ds.cursor(); inv; inv = gridControl_ds.getnext()) {    //logic here } gridControl_...

Vibe Power Apps: Build Enterprise Apps with AI in Minutes

Vibe Power Apps: The Future of Enterprise App Development Imagine walking up to a blank screen, typing "I need an incident reporting tool where users can log incidents, add witnesses, track severity, and see a dashboard" — and watching a complete, data-connected business application materialise in front of you in minutes. That's not a demo reel. That's Vibe Power Apps , Microsoft's newest — and most ambitious — leap in low-code development. The term "vibe coding" first surfaced in early 2025, describing an emerging style of software creation where developers describe intent in plain language and let AI handle the implementation. While consumer-focused tools like Cursor and Replit embraced this wave quickly, enterprises faced a harder question: where does vibe coding meet the regulatory guardrails, data governance, and integration depth that business-critical applications actually require? Microsoft...