How to Multiple 2 fields

rico1931
Member Posts: 295
Hi Everyone,
So I'm trying to modify the sales line table (37) to add a field I named "Total Net Weight"... All I would like it to do is take field 35 "Net Weight" and multiply it by the "Quantity" field 15 and display on my new field...
I first tried to set my new field to be a FlowField and use CalcFormula to summat the lines but I really don't think this is the proper way to do it. Can anyone provide any guidance?
Thank you
So I'm trying to modify the sales line table (37) to add a field I named "Total Net Weight"... All I would like it to do is take field 35 "Net Weight" and multiply it by the "Quantity" field 15 and display on my new field...
I first tried to set my new field to be a FlowField and use CalcFormula to summat the lines but I really don't think this is the proper way to do it. Can anyone provide any guidance?
Thank you
-rico1931
0
Best Answers
-
You need write code for it.
When do you want this calculation? After pressing any caption or entering any value.
You need to use onvalidate trigger or onpush action triggers..5 -
Okay the step would be like this
- Create a field in the Sales line table.
- On the OnValidate trigger of this field which you have created add the code to multiply the Quantity with Net weight and store in Total Net weight field like this
Total net weight field = Quantity * Net weight;
- On the sales line page, on the onValidate trigger of Quantity field do
SalesLine."Total Net Weight".OnValidate(TRUE);
this will call your table on validate trigger.
Thats it. Please verify my answer if it helps you.Best Regards
Zohaib Ahmed
Dynamics NAV ERP Technical Consultant.
please like / agree / verify my answer, if it was helpful for you. thanks.2
Answers
-
You need write code for it.
When do you want this calculation? After pressing any caption or entering any value.
You need to use onvalidate trigger or onpush action triggers..5 -
Okay the step would be like this
- Create a field in the Sales line table.
- On the OnValidate trigger of this field which you have created add the code to multiply the Quantity with Net weight and store in Total Net weight field like this
Total net weight field = Quantity * Net weight;
- On the sales line page, on the onValidate trigger of Quantity field do
SalesLine."Total Net Weight".OnValidate(TRUE);
this will call your table on validate trigger.
Thats it. Please verify my answer if it helps you.Best Regards
Zohaib Ahmed
Dynamics NAV ERP Technical Consultant.
please like / agree / verify my answer, if it was helpful for you. thanks.2 -
Thanks to the both of you! I think I understand what needs to be done... lol just one last thing.. anyone know of a good website or book to see example of how to set the variables I tried "Total Net Weight" = Quantity * Net Weight; but I need to set "Total Net Weight" variable and did it in the C/AL locals.
At this time I was thinking that maybe if I ran the table I could see the total net weight calculated but did not.
After that I went to the Sales Line Order subform to do what you both said and use the onvalidate trigger in the "Quantity" field...
Only problem here is that for some reason SalesLine."Total Net Weight".OnValidate(TRUE); won't work because SalesLine is an unknown variable... but how so when it's the table that is attached to the sales order subform?
So I went into the C/AL Globals and defined SalesLine as a record with subtype Sales Line and now it's telling me the variable is not a record. "Variable.Field" is invalid. But I thought that's how you always called fields that are in a table?-rico19310 -
You need to make a variable say SalesLine having Type Record and sub type 37 (Sales line)Best Regards
Zohaib Ahmed
Dynamics NAV ERP Technical Consultant.
please like / agree / verify my answer, if it was helpful for you. thanks.0 -
Thanks Zohaibu95 ... That's exactly what I thought and did but it still gives me the "Variable.Field" is invalid-rico19310
-
Remove SalesLine and then try?
Also press f5 and check in the symbol menu whether the onValidate trigger is available or not?Best Regards
Zohaib Ahmed
Dynamics NAV ERP Technical Consultant.
please like / agree / verify my answer, if it was helpful for you. thanks.0 -
oh boy.. so removing SalesLine was correct and I see now that using the symbol menu is much easier to find and insert records, thank you for that.
Looks like everything that is available is a function... and to my knowledge the functions are from codeunits that I'm not entirely ready to start messing with lol. But hey please let me know if I'm wrong.-rico19310 -
You need to use Rec variable from symbol menu0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions