{"id":585,"date":"2019-12-03T12:55:02","date_gmt":"2019-12-03T11:55:02","guid":{"rendered":"http:\/\/daxvisionerp.com\/?p=585"},"modified":"2025-10-27T08:18:04","modified_gmt":"2025-10-27T08:18:04","slug":"finditempriceagreement-is-obsolete-use-the-instance-method-pricedisc-findprice-instead","status":"publish","type":"post","link":"https:\/\/daxvisionerp.com\/home\/finditempriceagreement-is-obsolete-use-the-instance-method-pricedisc-findprice-instead\/","title":{"rendered":"&#8216;findItemPriceAgreement&#8217; is obsolete. Use the instance method PriceDisc.findPrice instead."},"content":{"rendered":"\n<p>This is an example of a code upgrade from Ax 2012 R3 to D365FO. It is not so hard to figure out but might save 30-60 minutes for someone else out there. PriceDisc::findItemPriceAgreement(&#8230;) call needs to be replaced by &nbsp;priceDisc.findPrice(&#8230;) as stated in the compilation error, but &#8216;findPriceAgreement&#8217; has many parameters while &#8216;findPrice&#8217; has only one.  The solution is to use the &#8216;PriceDiscParameters&#8217; class. Using its &#8216;parm&#8217; methods, set the parameters that were before separate parameters of the &#8216;findPriceAgreement&#8217; static method, after that call &#8216;PriceDisc::newFromPriceDiscParameters(priceDiscParameters)&#8217; to create an intance of PriceDisc  See an example below:<\/p>\n\n\n\n<p>AX2012 code:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">private PriceCur getPurchasePrice(ItemId _item, ReqQty _reqQty, TransDate _priceDate)\n{\n    PriceCur            purchPrice = 0;\n    InventTableModule   inventModule;\n    TransDate           priceDate  = _priceDate;\n    PriceDisc           priceDisc;\n    \n    if(jjeParameters.TradePriceByDueDate == NoYes::No)\n    {\n        priceDate = SystemDateGet();\n    }\n    inventModule = InventTableModule::find(_item, ModuleInventPurchSales::Purch);\n    [ purchPrice ] = PriceDisc::findItemPriceAgreement(inventModule.ModuleType, _item, inventDim, inventModule.UnitId, priceDate, _reqQty, vendTable.AccountNum, vendTable.Currency, '');\n\n    return purchPrice;\n}\n<\/pre>\n\n\n\n<p>Code upgraded to D365FO:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>private PriceCur getPurchasePrice(ItemId _item, ReqQty _reqQty, TransDate _priceDate)\n{\n    PriceCur            purchPrice = 0;\n    InventTableModule   inventModule;\n    TransDate           priceDate  = _priceDate;\n    PriceDisc           priceDisc;\n    PriceDiscParameters parameters = PriceDiscParameters::construct();\n\n    if(jjeParameters.TradePriceByDueDate == NoYes::No)\n    {\n        priceDate = DateTimeUtil::getSystemDate(DateTimeUtil::getUserPreferredTimeZone());\n    }\n    inventModule = InventTableModule::find(_item, ModuleInventPurchSales::Purch);\n\n    parameters.parmModuleType(ModuleInventPurchSales::Purch);\n    parameters.parmItemId(_item);\n    parameters.parmInventDim(inventDim);\n    parameters.parmUnitID(inventModule.UnitId);\n    parameters.parmPriceDiscDate(priceDate);\n    parameters.parmQty(_reqQty);\n    parameters.parmAccountNum(vendTable.AccountNum);\n    parameters.parmCurrencyCode(vendTable.Currency);\n    priceDisc = PriceDisc::newFromPriceDiscParameters(parameters);\n\n    priceDisc.findPrice('');\n        \n    return priceDisc.price();\n}<\/code><\/pre>\n\n\n\n<p><a href=\"https:\/\/github.com\/PeterProkopecz\/AX\/tree\/master\/D365FO_Upgrade_PriceDisc_FindPrice\" target=\"_blank\" rel=\"noopener\">https:\/\/github.com\/PeterProkopecz\/AX\/tree\/master\/D365FO_Upgrade_PriceDisc_FindPrice<\/a><\/p>\n\n\n\n<p><\/p>\n\n\n<div class=\"taxonomy-post_tag wp-block-post-terms\"><a href=\"https:\/\/daxvisionerp.com\/home\/tag\/msdyn365fo\/\" rel=\"tag\">#MSDyn365FO<\/a><span class=\"wp-block-post-terms__separator\">, <\/span><a href=\"https:\/\/daxvisionerp.com\/home\/tag\/code-upgrade\/\" rel=\"tag\">Code upgrade<\/a><\/div>","protected":false},"excerpt":{"rendered":"<p>This is an example of a code upgrade from Ax 2012 R3 to D365FO. It is not so hard to figure out but might save 30-60 minutes for someone else out there. PriceDisc::findItemPriceAgreement(&#8230;) call needs to be replaced by &nbsp;priceDisc.findPrice(&#8230;) as stated in the compilation error, but &#8216;findPriceAgreement&#8217; has many parameters while &#8216;findPrice&#8217; has only [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_et_pb_use_builder":"","_et_pb_old_content":"","_et_gb_content_width":"1080","footnotes":""},"categories":[19],"tags":[25,55],"class_list":["post-585","post","type-post","status-publish","format-standard","hentry","category-dynamics-365fo","tag-msdyn365fo","tag-code-upgrade"],"_links":{"self":[{"href":"https:\/\/daxvisionerp.com\/home\/wp-json\/wp\/v2\/posts\/585","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/daxvisionerp.com\/home\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/daxvisionerp.com\/home\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/daxvisionerp.com\/home\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/daxvisionerp.com\/home\/wp-json\/wp\/v2\/comments?post=585"}],"version-history":[{"count":1,"href":"https:\/\/daxvisionerp.com\/home\/wp-json\/wp\/v2\/posts\/585\/revisions"}],"predecessor-version":[{"id":1393,"href":"https:\/\/daxvisionerp.com\/home\/wp-json\/wp\/v2\/posts\/585\/revisions\/1393"}],"wp:attachment":[{"href":"https:\/\/daxvisionerp.com\/home\/wp-json\/wp\/v2\/media?parent=585"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/daxvisionerp.com\/home\/wp-json\/wp\/v2\/categories?post=585"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/daxvisionerp.com\/home\/wp-json\/wp\/v2\/tags?post=585"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}