Sankar R
Sankar R

Reputation: 45

How to update temp table data during run time AX 2012

I'm new to X++ development. I'm trying to add a field in Vendor aging report. It was done as excepted.

my problem is updating the field value during run time.

Scenario, We have a Invoice field contain "AA_BBBBBB". What I need to do is I need to split the value as AA, BBBBBB and update BBBBBB to invoice field and AA to new field (Invoice type).

Issue, Once i got the values to temptable VendAgingReportTmp in the method VendAgingReportDP\insertVendAgingReportTmp, I'm tried to update the above scenario but code is not selecting the records from VendAgingReportTmp. Can someone help me to get this thing done.

Upvotes: 0

Views: 5274

Answers (2)

Sankar R
Sankar R

Reputation: 45

I got a solution by adding below,

  • Added InvoiceType field to temptable VendTmpAccountSum Since this is declared as global variable.
  • Updated our custom Invoice type to InvoiceType field in VendTmpAccountSum.
  • Then insert the whole data to VendAgingReportTmp from VendTmpAccountSum table by using insert_recordset to increase the performance.

Thanks,

Upvotes: 0

Jonathan Bravetti
Jonathan Bravetti

Reputation: 2236

In VendAgingReportDP class insertVendAgingReportTmp the last line of standard code is vendAgingReportTmp.insert();

If your code is before vendAgingReportTmp.insert(); You do not need to perform the update. If you put vendAgingReportTmp.update(); before vendAgingReportTmp.insert(); you get that error.

Put your code inside //YourCode and //YourCode END withhout vendAgingReportTmp.update();

Example:

/// <summary>
///    Inserts records into the temporary <c>VendAgingReportTmp</c> table.
/// </summary>
/// <param name="_reverseAmountsAndHeadings">
///    A boolean value which indicates whether the column values should be     reversed.
/// </param>
private void insertVendAgingReportTmp(boolean _reverseAmountsAndHeadings)
{
    vendAgingReportTmp.AsOfDate = strFmt("@SYS84682",     date2StrUsr(contract.parmZeroDate(), DateFlags::FormatAll),     contract.parmDateTransactionDuedate());
    vendAgingReportTmp.HeadingAccount = strFmt("@SYS24500");
    vendAgingReportTmp.HeadingName = strFmt("@SYS7399");

    switch (contract.parmDateTransactionDuedate())
    {
        case DateTransactionDuedate::DocumentDate : vendAgingReportTmp.HeadingDate = "@SYS2587";
                                                break;
        case DateTransactionDuedate::TransactionDate : vendAgingReportTmp.HeadingDate = "@SYS67";
                                                break;
        case DateTransactionDuedate::DueDate : vendAgingReportTmp.HeadingDate =     "@SYS14588";
                                                    break;
        default : vendAgingReportTmp.HeadingDate = "@SYS14588";
                                                    break;
    }

    if (_reverseAmountsAndHeadings)
    {
        this.setVendAgingReportTmpInReverse();
    }
    else
    {
        this.setVendAgingReportTmp();
    }

    vendAgingReportTmp.TransDate = tmpAccountSum.TransDate;
    vendAgingReportTmp.InvoiceId = tmpAccountSum.InvoiceId;
    vendAgingReportTmp.Voucher = tmpAccountSum.Voucher;
    vendAgingReportTmp.AccountNum = tmpAccountSum.AccountNum;
    vendAgingReportTmp.Name = vendTable.name();
    vendAgingReportTmp.VendAccount = tmpAccountSum.AccountNum;
    vendAgingReportTmp.Txt = tmpAccountSum.Txt;
    vendAgingReportTmp.Balance = 100;
    vendAgingReportTmp.CurrencyCode = tmpAccountSum.CurrencyCode;
    vendAgingReportTmp.VendGroup = vendTable.VendGroup;

    //YourCode
    //...
    //...
    //...
    //YourCode END

    vendAgingReportTmp.insert();
}

Upvotes: 1

Related Questions