Tuesday, 5 September 2017

AX: Get Record Starts With Any Specific Letter

I came across a scenario in which I need to update the those customer records which starts with any particular Letter Let’s suppose Letter  ‘T’ in my case, Below Job is used to update the sales district of all customer account starts with Letter ‘T’.

static void UpdateCustSalesDistrictStartsWith_TK(Args _args)
{
    CustTable           custTable;
    CustAccount         customerAccountStartsWith;
    smmSalesDistrictId  salesDistrict;
    int                 records;

    customerAccountStartsWith ='T';
    salesDistrict = North;

       while select forupdate custTable
              where custTable.AccountNum like customerAccountStartsWith +"*"
              {
                  records++;
                  ttsbegin;
                    custTable.SalesDistrictId = salesDistrict;
                    custTable.doupdate();
                  ttscommit;

              }
           info(strFmt("Total Records updated = %1", records));

}

No comments:

Post a Comment