How to Multiple 2 fields

rico1931rico1931 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
-rico1931

Best Answers

  • zohaibu95@hotmail.comzohaibu95@hotmail.com Member Posts: 223
    edited 2017-01-27 Answer ✓
    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.

Answers

  • zohaibu95@hotmail.comzohaibu95@hotmail.com Member Posts: 223
    edited 2017-01-27 Answer ✓
    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.
  • rico1931rico1931 Member Posts: 295
    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?
    -rico1931
  • zohaibu95@hotmail.comzohaibu95@hotmail.com Member Posts: 223
    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.
  • rico1931rico1931 Member Posts: 295
    Thanks Zohaibu95 ... That's exactly what I thought and did but it still gives me the "Variable.Field" is invalid
    -rico1931
  • zohaibu95@hotmail.comzohaibu95@hotmail.com Member Posts: 223
    edited 2017-01-27
    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.
  • rico1931rico1931 Member Posts: 295
    edited 2017-01-30
    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.
    -rico1931
  • mohana_cse06mohana_cse06 Member Posts: 5,504
    You need to use Rec variable from symbol menu
Sign In or Register to comment.