hljs.configure({cssSelector: "code"}); hljs.highlightAll();

Thursday, January 28, 2021

Avoid Duplicates In LookUp In Ax/D365Fo

Static void Job1()

   Query query = new Query();

    QueryBuildDataSource qbds1;

    QueryBuildRange qbr;

    SysTableLookup sysTableLookup;

    sysTableLookup = sysTableLookup::newParameters(tablenum(InventTable),this);

    sysTableLookup.addLookupfield(fieldnum(InventTable,ItemId));

    sysTableLookup.addLookupfield(fieldNum(InventTable,ItemId)); 

    qbds1 = query.addDataSource(tableNum(InventTable));

    qbds1.addGroupByField(fieldNum(InventTable,ItemId));

    qbds1.orderMode(OrderMode::GroupBy);

    sysTableLookup.parmQuery(query);

    sysTableLookup.parmUseLookupValue(False);

    sysTableLookup.performFormLookup();

}

Wednesday, January 27, 2021

X++ Code to Retrieve Customer Contact information in AX/D365Fo

 

static void Getcontact(Args _args)

{

    CustTable                   custTable;

    DirPartyLocation            dirPartyLocation;

    LogisticsElectronicAddress  logisticsElectronicAddress;

    select firstOnly * from custTable

        where custTable.AccountNum == 'us-002'

    join dirPartyLocation

        where custTable.Party == dirPartyLocation.Party

    join logisticsElectronicAddress

        where logisticsElectronicAddress.Location == dirPartyLocation.Location

    && logisticsElectronicAddress.Type == LogisticsElectronicAddressMethodType::Phone;

    info(strFmt("Customer: %1, PostalAddress: %2",  custTable.AccountNum,                                                   logisticsElectronicAddress.Locator));


}

Cannot edit a record in Order lines (SalesLine). An update conflict occurred due to another user process deleting the record or changing one or more fields in the record.

Some times when we perform delete or update actions then we might get error like 

"Cannot edit a record in Order lines (SalesLine). An update conflict occurred due to another user process deleting the record or changing one or more fields in the record."

Solution for this error is just add reread() before update statement.

salesLine.Reread()

salesLine.Update();


 Reference :Refer to this