Table find method to find item id's in x++

   static BASTradeAgreementTable find(ItemId          itemId,

                           boolean          _forUpdate = false,

                           ConcurrencyModel _concurrencyModel = ConcurrencyModel::Auto)

    {

        BASTradeAgreementTable  basTradeAgreementtable;


        if (itemId)

        {

            if (_forUpdate)

            {

                basTradeAgreementtable.selectForUpdate (_forUpdate);

                if (_concurrencyModel != ConcurrencyModel::Auto)

                {

                    basTradeAgreementtable.concurrencyModel(_concurrencyModel);

                }

            }

            basTradeAgreementtable.selectLocked    (_forUpdate);


            select firstonly basTradeAgreementtable

                where basTradeAgreementtable.ItemId == itemId;

        }


        return basTradeAgreementtable;

    }


}


To check whether itemid is present in the table we can check like this:

  BASTradeAgreementTable tradeAgreement= BASTradeAgreementTable::find('0001');


        info(strFmt("%1",tradeAgreement.ItemId));


Comments

Popular posts from this blog

How to Create a wizard in x++ d365

how to post trade agreement journals automatically using x++ code

X++ code to CREATE AND POST A TRADE AGREEMENT IN MICROSOFT DYNAMICS 365 in D365 F & O