Can't retrieve the Amount Including VAT value

ombacke
ombacke Member Posts: 44
Hi Guys,
I wrote some code that goes into the Sales Hearder Table and i'm trying for a record to get the value of the Amount Including VAT field.

refTable.OPEN(intTableNo);
refTable.GET(recId);
refField := refTable.FIELD(intFieldNo);

IF UPPERCASE(FORMAT(refField.TYPE)) = 'OPTION' THEN
txtFieldValue := FORMAT(refField.OPTIONCAPTION)
ELSE
txtFieldValue := FORMAT(refField.VALUE()) ;

intTableNo is the id of the table, intFieldNo, is the ID of the field here it is 61 but when this is done the txtFieldValue is always set to 0 even if for the record there actually is a value different from 0. (I ran the table and the form and found these out)..
I reaaly need some help..
Thank you

Comments

  • ara3n
    ara3n Member Posts: 9,258
    refTable.GET(recId);

    GET paramater are primary key of the table. In your case, You have Only the Document No.. You need the document type.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • ombacke
    ombacke Member Posts: 44
    Thanks for the answer.. And how would I get the Document Type?
  • ara3n
    ara3n Member Posts: 9,258
    well quote is 0, order is 1, invoice is 2

    Something like this;


    refTable.GET(1,recId);


    I don't know the reason why you are using reftable instead of record type.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • Kowa
    Kowa Member Posts: 926
    "Amount Including VAT" is a flowfield , so a CALCFIELDS is necessary to retrieve the amount.
    Kai Kowalewski
  • Phenno
    Phenno Member Posts: 630
    Kowa wrote:
    "Amount Including VAT" is a flowfield , so a CALCFIELDS is necessary to retrieve the amount.
    And it holds a value only when Status is Launched.
  • ombacke
    ombacke Member Posts: 44
    So what would be the best way to get its value? Should I get all the salelines for that salesheader and add up their amount values?
  • Phenno
    Phenno Member Posts: 630
    ombacke wrote:
    So what would be the best way to get its value? Should I get all the salelines for that salesheader and add up their amount values?

    You do have "Amount with VAT" sum in Sales Header table and it's in a form of a flow field (so, through code you have to do CALCFIELDS before using it) and it has a value only when sales order is launched (if you want to get values for sales orders).
  • ombacke
    ombacke Member Posts: 44
    Thank you very much Pheno your solution solved my problem, I needed to use calcfield...
    Now I have another question: In C/Side is the a way once you have a reference to the field refField to know whether the field is a FlowField or not through code??
  • Phenno
    Phenno Member Posts: 630
    ombacke wrote:
    Thank you very much Pheno your solution solved my problem, I needed to use calcfield...
    Now I have another question: In C/Side is the a way once you have a reference to the field refField to know whether the field is a FlowField or not through code??

    When I don't know what properties and methods I have on a single type of var, I usually insert one testing global var (for your example with type of: FieldRef). After that, you can use C/AL Symbol Menu (or F5), find that var and check what can you do with that type of var.

    In your example, there is a CLASS property that says is it a flowfield, flowfilter or regular field.