HI,
I try to change items prices for purchase orders. Going from project I'm creating a purchase order. After I accept it on PurchCreateFromSalesOrder form the new created order prices are 0 but I want that it gets the prices from the previous form on created. And of top ot that it should not change the prices on project when I modify the price on purchase order. Actually when I change the price on my order the price also changes on project * exchangerate.
Which class/method can bring me close to solution of this?
Im looking on PurchAutoCreate_sales class and createlines method but looks like im wrong here.
I'm not sure if I understand - could you clarify if you have one problem/question or two separate ones.
Did you customize the price handling in PurchCreateFromSalesOrder? At least you asked about it recently (community.dynamics.com/.../insert-value-into-purchaseprice-field).
Please try to run the process without your customization, so that you can see how it works normally.
If you notice that your customization causes issues, please analyze it. And of course you can share your code here if you need our inputs.
I create a service order > add Project item requiement > and create a purchase order from it.
My last thread is solved ( at least it is doing what I wanted to do). My code adds prices in PurchCreateFromSalesOrder form like I wanted but now I want to pass it further directly into a purchase order. For now the created order has no prices values in it and when I add them manually the price also changes in project item requiment what i don't want to.
Perhaps your code in PurchCreateFromSalesOrder is not correct. But it's hard to tell without seeing your code. If you want us to take a look, feel free to share it. Thanks!
I can see that some suggested code in the other thread would be completely wrong.
[Extensionof(formDataSourceStr(PurchCreateFromSalesOrder, SalesLine))] final class SalesLineSZM_Extension { public real exchRate, purchprice = 0; private ServiceParametersSz serviceparm; public void ExchangeRateCur(SalesLine _salesline) { ExchangeRate exchangeRate; ExchangeRateType ExchangeRateType; ExchangeRateCurrencyPair exchangeRateCurrencyPair; if(curExt() == 'SZM' )//&& serviceparm.AutoFillServiceData == true) { CurrencyCode fromCurrency = "EUR"; CurrencyCode toCurrency = Ledger::find(Ledger::current()).AccountingCurrency ; TransDate transDate = today(); if(_salesLine.CurrencyCode != "PLN") { select firstonly exchangeRateCurrencyPair where exchangeRateCurrencyPair.ExchangeRateType == Ledger::find(Ledger::current()).DefaultExchangeRateType && exchangeRateCurrencyPair.FromCurrencyCode == fromCurrency && exchangeRateCurrencyPair.ToCurrencyCode == toCurrency; exchRate = exchangeRate::findByDate(exchangeRateCurrencyPair.RecId,transDate).ExchangeRate; purchprice = _salesLine.SalesPrice * exchRate/100; // Info(strFmt("%1,%2",serviceparm.AutoFillServiceData,curExt())); } else { purchprice = _salesLine.SalesPrice; } } } //this.ExchangeRateCur(_salesLine); [SysClientCacheDataMethodAttribute(true)] edit Price specifyUnitPrice(boolean _set, SalesLine _salesLine, Price _price) { next specifyUnitPrice(_set, _salesLine, _price); this.ExchangeRateCur(_salesLine); return PurchPrice; // _salesLine.SalesPrice * ExchRate/100; } [SysClientCacheDataMethodAttribute(true)] display AmountCur netAmount(SalesLine _salesLine) { next NetAmount(_salesLine); return PurchPrice; //_salesLine.SalesPrice * ExchRate/100; } [SysClientCacheDataMethodAttribute(true)] display AmountMST netAmountMST(SalesLine _salesLine) { next netamountmst(_salesLine); return PurchPrice; //_salesLine.SalesPrice * ExchRate/100; } }
The problem is in specifyUnitPrice.
The standard method is displaying and updating values from the tmpPurchLinePrice table.
But you are bypassing this when the value is displayed. So, you display something else, but the tmp table still has some other value. And this other value is passed on in the process.
You need to fix your customization in a way that you update tmpPurchLinePrice table with your "PurchPrice".
Hi
Try this code,
[Extensionof(formDataSourceStr(PurchCreateFromSalesOrder, SalesLine))] public final class PurchCreateFromSalesOrder_Extension { [SysClientCacheDataMethodAttribute(true)] edit Price specifyUnitPrice(boolean _set, SalesLine _salesLine, Price _price) { PurchPrice price = 200; // Your price calculation object salesLineds = element.dataSource(formDataSourceStr(PurchCreateFromSalesOrder, SalesLine));; next specifyUnitPrice(_set, _salesLine, _price); salesLineds.specifyPriceComponent(true, _salesLine,fieldNum(TmpPurchLinePrice,Price), price); return price; } }
Uday
Thank you.
Now tle last thing I need is to prevent from updating prices on proj sales itemreq when changing prices on orders.
ACtually when order currency is different from project currency it recalculate it on project.
Could someone advice me in this one more thing?
I want to prevent from changing salesitemreq prices when changing them manually on purchase orders.
Could I archive it by extending purchline method from below or should I look on something else?
public FieldId parmManualModifiedField(FieldId _manualModifiedField = 0) { if (!prmisDefault(_manualModifiedField)) { this.setField(fieldNum(PurchLine, ManualModifiedField), _manualModifiedField); } return purchLine.ManualModifiedField; }
Did you debug it to see which class is doing the update of SalesItemReq price? Please share your learnings with us, perhaps we can suggest how to disable the logic (if possible).
I did try it but I'm bad at it I don't know how to debug it the right way to know exactly what is going on the right moment.
I just tried to debug the modify methods there but had no reply (nothing is showed like it didn't run, didnt hit my brakpoints).
Under review
Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
CA Neeraj Kumar 813
André Arnaud de Cal... 738 Super User 2025 Season 2
Sohaib Cheema 566 User Group Leader