Hi,
I am quite new to programming in Dynamics Nav 5.0. I am trying to create a field in the sub-formular for sales order which shown the margin in precentage in relation to Unit Price and Unit Cost, eg. ("Unit Price" - "Unit Cost") / Unit Price. This results in execution error because division by zero is not possible since the user needs to put in the Unit Price before first calculation.
Where do I add this logic ? And how do I get a calc-execution each time the user fills in a new Unit Price ?
B.rgd
Jens
0
Answers
RIS Plus, LLC
Otherwise I don't need the column, isn't it better to create a function inside the form itself that passes two varibles which would be the Unit Price and Unit Cost ?
B.rgd
Jens
http://www.BiloBeauty.com
http://www.autismspeaks.org
RIS Plus, LLC
Tino Ruijs
Microsoft Dynamics NAV specialist
I added the function to Sales Line (not Sales Header), but I had to add a varible on Form 46 (Sub Order Form) to Sales Line table (Record). I put a text box on the Sub Order Form which gets SalesLine.CalcMarginPercentage()
The problem now is that everything gets valued(evaluted) as zero(no Unit Price set, but it's set on the form), which means it always shows 0%. I assume this has something do to that the current record is not correctly referenced when I added Sales Line on the C/AL globals.
Any hints for a newbi ?
B.rgd
Jens
http://www.BiloBeauty.com
http://www.autismspeaks.org
Also you will have to call it from OnValidate of the"No." field
and again on the Validate of "Unit Price" in case it's manually changed.
Unless you want it to also calculate correctly if an Item discount is entered or some other senarios :-k
Ohh..now reading the other posts I thought this was about adding a Markup PER ITEM. Do you want the Order total Markup?
I know the Profit% field on the Order Statistics (F9) works fine.
http://www.BiloBeauty.com
http://www.autismspeaks.org
RIS Plus, LLC
Now everything works fine, the problem were that you should only write CalcMarginPercentage() in the SourceExpr. It does not work to reference Sales Line in the same form.
It seems to be updated as soon the user changes the price so I can't see any need to add the call on onValidate etc.
How do I format the column to contain a percentage mark,%, ?
B.rgd
Jens
'%'+FORMAT(yourPercentMarkupfield,5)
http://www.BiloBeauty.com
http://www.autismspeaks.org
Thanks everyone.
B.rgd
Jens