Sunday, May 28, 2017

Update customer based on Selection fields in AX

static void updateCustomerStd(Args _args)
{
    CustTable   custTable,getcustTable;
   
    //Function to set customer record
    CustTable createCustTable(CustTable   _custTable)
    {
        AxCustTable     axCustTable;
        SysDictTable    sysDictTable = new SysDictTable(tableNum(CustTable));
        int             i;
        int             fieldCnt;
        FieldId         fieldId;
        ;
        ttsbegin;
        axCustTable = AxCustTable::constructValidateInput(_custTable);
        fieldCnt = sysDictTable.fieldCntWithoutSys();
        for (i=1;i <= fieldCnt;i++)
        {
            fieldId = sysDictTable.fieldCnt2Id(i);
            if (fieldNum(CustTable, AccountNum) != fieldId)
                axCustTable.setFieldAsTouched(fieldId);
        }
        axCustTable.save();
        ttscommit;
        return axCustTable.custTable();
    }
    ;
    ttsBegin;
    select forupdate custTable;
    info(custTable.AccountNum + " " + custTable.CustGroup + " " + custTable.InvoiceAccount);
    custTable.CustGroup = "Corporate";
    custTable.InvoiceAccount = "CH0000239";
    getcustTable = createCustTable(custTable);
    info(getcustTable.AccountNum + " " + getcustTable.CustGroup + " " + getcustTable.InvoiceAccount);
    ttsCommit;
}

No comments:

Post a Comment

Copy Markup charges while posting purchase invoice using X++

 Copy Markup charges while posting purchase invoice using X++ Class: Important: Code logic is just for Reference.  New class => Duplicate...