Announcements
My end goal is to get the unit price for an item from a purchase agreement with X++ code. I'm having a hard time figuring out where to access this information. All I currently have available to me in my code is the Vendor information and the item, but not even what Purchase Agreement Number. I'm working with the assumption that a vendor will not have a given item in multiple PA's.
My first thought is to find the PA and then access the PA Lines to get the Unit Price for the item. If there's a better way I would love to hear it. Currently in the All Vendors List Page you can click the Procurement Tab and then the Purchase Agreements Button with a vendor selected to be taken to the Purchase Agreements List Page filtered to just that vendor. I can't figure out how to duplicate this functionality in my own code. Since I have the vendor information already my plan is to find all the PA's for that vendor, then search the PA's for the item I'm looking for and then get the Unit Price for that item from the PA Line.
I'm not sure this is the way I should be trying to do this, but it's the best idea I have for accessing this information, presently.
*This post is locked for comments
If you want to do this in D356O, check the below link as "PriceDisc::findItemPriceAgreement()" is deprecated in D365O.
1824pranav.blogspot.com/.../find-price-disc-trade-agreements-in.html
Hi
Did you solve this?
Thanks.
Ok, I found out I am getting results, just not what I'm looking for. Right now I'm getting the price from the item details page where you set a purchase price:
But I'm looking for the price from a purchase agreement:
My updated code is:
static void GetPriceFromItemAndVendor(Args _args) { InventTable inventTable = inventTable::find('10000'); InventDim inventDim; ItemId ItemId; UnitOfMeasureSymbol UnitId; TransDate TransDate; PriceDisc PriceDisc; container result; InventDim.initFromInventTable(inventTable); ItemId = "10000"; UnitId = "Pcs"; TransDate = today(); result = PriceDisc::findItemPriceAgreement(ModuleInventPurchSales::Purch, ItemId, inventDim, UnitId, TransDate, 10000, "1001", "USD", "0"); }
Which returns 399 as the price.
edit: Updated below. Unsure on how to delete a post.
Please ensure that you have data as per the parameter you are passing
like
Inventory Dimension
UnitId and valid price agreement data for today
Please review and update us with your findings
Thanks for introducing me to this class, it is just what I need, although I am having trouble learning to use it my first time. I'm writing a job to try and get an example of this working. Below is the code I have so far, it compiles and runs fine, but the container just contains zeros for the most part so I assume it is not finding anything. It's likely a problem with the parameters I am giving the method, being my first time attempting to use it and an unfamiliarity with the parameter types I'm sure I've made some mistakes.
InventDim InventDim; ItemId ItemId; UnitOfMeasureSymbol UnitId; TransDate TransDate; PriceDisc PriceDisc; container result; InventDim = InventDim::findOrCreateBlank(); ItemId = "10000"; UnitId = "Pcs"; TransDate = today(); result = PriceDisc::findItemPriceAgreement(ModuleInventPurchSales::Purch, ItemId, InventDim, UnitId, TransDate, 10000, "1001","USD", "0");
please utilize following link with more details
msdn.microsoft.com/.../pricedisc.finditempriceagreement.aspx
Please verify and let us know if this helps you
Use the following method of PriceDisc class.
static container findItemPriceAgreement(ModuleInventPurchSales _moduleType,
ItemId _itemId,
InventDim _inventDim,
UnitOfMeasureSymbol _unitID,
TransDate _priceDate,
Qty _qty,
CustVendAC _accountId,
CurrencyCode _currency,
PriceGroupId _priceGroupId)
{
PriceDisc priceDisc;
;
priceDisc = new PriceDisc(_moduleType,
_itemId,
_inventDim,
_unitID,
_priceDate,
_qty,
_accountId,
_currency);
priceDisc.findPrice(_priceGroupId);
return [priceDisc.price(),
priceDisc.markup(),
priceDisc.priceUnit(),
priceDisc.deliveryDays(),
priceDisc.calendarDays()];
}
It will give you a container containing Price unit.
Hope this helps you
André Arnaud de Cal...
293,311
Super User 2025 Season 1
Martin Dráb
232,183
Most Valuable Professional
nmaenpaa
101,158
Moderator