New Function in Codeunit 7000 & 7010
Hi,
we need a new external function in Codeunits 7000 and 7010.
With that function it should be able to set variables used in the codeunit.
Without that function the external function "FindSalesPrice" and "FindPurchPrice" cannot be used, as Currency, vat and UoM are not set.
The function could/should look like this:
[External] M365_SetVariabel(itemNoL : Code[20];currencyCodeL : Code[10];currencyfactorL : Decimal;currencyDateL : Date;qtyL : Decimal;qtyPerUoML : Decimal)
Item.GET(itemNoL);
SetCurrency(currencyCodeL,currencyfactorL,currencyDateL);
SetVAT(FALSE,0,0,'');
SetUoM(ABS(qtyL),qtyPerUoML);
Parameters are:
itemNoL : Code[20]; currencyCodeL : Code[10]; currencyfactorL : Decimal; currencyDateL : Date; qtyL : Decimal; qtyPerUoML : Decimal
thanks
Hi Lennart. Short question about new function you ask. There are events OnBeforeFindSales(Purch)Price and there are all required parameters with var. Why can't you use it to get what you want?
Hi, The problem with that solution ist, that the variables i used when calling FindSalesPrice will not be available in the subscriber...
Not sure I fully understand you. Below is part of FindSalesPrice with call of event, which variables are not available in the subscriber?
[External] FindSalesPrice(...) ... OnBeforeFindSalesPrice( ToSalesPrice,FromSalesPrice,QtyPerUOM,Qty,CustNo,ContNo,CustPriceGrCode,CampaignNo, ItemNo,VariantCode,UOM,CurrencyCode,StartingDate,ShowAll);
Hi, lets say i have an action on a page, where i got a qty saved in a local variable. Then i want to use that qty in the FindSalesPrice. So i call the FindsalesPrice. The event is triggerd and i have to create a subscriber. In that new subscriber i dont have access to the local qty variable. Thats my problem :)
Ok, now it more or less clear. Let me suggest you the following solution. You have a subscriber codeunit with a function subscribed on the "OnBeforeFindSalesPrice". You need to pass a parameter there. Then you need one more event OnSomeAction, your own and one more subscriber function. This subscriber function should be in the same codeunit as the subscriber on the "OnBeforeFindSalesPrice" one. Then in the place where you are going to call FindSalesPrice function and where you know the value of your parameter, you need manually (BINDSUBSCRIPTION) subscribe your codeunit, call the "OnSomeAction" event, pass your parameter there. And in the subscriber function in your codeunit set a global variable with the value of parameter from event. Then when subscriber function for OnBeforeFindSalesPrice will be called, you can read the global variable set before and pass it further in the event. Does it look like a working schema for you?
Hi, This doesnt look like a working schema for us. If we would do it like you suggest, the subscriber would be called every time the FindSales(Purch)Price would be used. That wouldnt work, becouse in the subscriber we cannot see, where we originaly came from. Additionally, if we use the pubisher, only the local variables in the function will be set. By Using out suggested function, we would be able to set the global variables, wich would be important for us.
Hi. I still suggest to observe suggestion one more time. The first thing is that you can make manual subscription and then subscriber will not be called any time, only when you do BINDSUBSCRIPTION. According to my suggestion you can also pass parameter to subscriber codeunit (for example) by setting a global variable in it and then reading it in other subscriber function. Or in extreme case you can use single instance codeunit to read/write variables. The second thing there are local functions that sets VAT, UoM, Currency, I plan to make them global.
HI, i hope if you say you are making them global means external aswell? Will it be possible to set the Global Item?