Possible for flowfield's CalcFormula to reference own table?

juicerjuicer Member Posts: 3
Someone created an "Item Tracking Required" flowfield on our Purchase Line table to help the end-user easily notice if there is item tracking for an item. This flowfield has been added to the PO subform. Here's the flowfield's calcformula:

Exist(Item WHERE (No.=FIELD(No.),Item Tracking Code=FILTER(<>'')))

This works fine when "Purchase Line".Type is Item, but sometimes confusing when Type is G/L Account. Confusing because some G/L Account numbers are identical to Item numbers having Item Tracking Codes.

So, I want the flowfield calcformula to work when the Purchase Line's Type is Item, and not work when it is G/L Account. I don't know how to write the calcformula to check the value in the Purchase Line's Type field, and execute accordingly. Any ideas?

I have a partial solution that I do not like. In the PO subform's OnAfterGetRecord I can put code to ignore the calcformula when the Type is not Item. Here's the code:
IF Type <> 2 THEN //2 is type Item
BEGIN
"Item Tracking Required" := FALSE;
END;

But this solution does not address the issue at the table level.

Thanks in advance for help.

Comments

  • SavatageSavatage Member Posts: 7,142
    have you tried adding to the calcformula type=item?

    use the assist edit.
  • garakgarak Member Posts: 3,263
    As Harry said, use also the Type in your calcformula.
    It's the same principle like on field "Qty. on Sales Order" in the item talble.

    Regards
    Do you make it right, it works too!
  • juicerjuicer Member Posts: 3
    Thanks for your replies. I am new to navision and calcformulas. Please help me understand. It seems your replies assume that Type is in the Item table, rather Type in the Purchase Line table which is also where the flowfield is.
    Using the elipses, I am only able to select fields in the Item table. I want to reference the Purchase Line table's own Type field. I am wondering if there is a way to do this.

    Basically, I want to enable the flowfield (in Purchase Line) when the Type (in Purchase Line) is 'Item'.

    Please let me know if I am still unclear, or if I am missing something.
    Thanks.
  • SavatageSavatage Member Posts: 7,142
    Oh I thought your were working only with the Puchase line.
    so the tracking no thing is on the item card.
    leave the field as type boolean but remove the calcformula

    Anyway how about on after validate of the item number on the purchase line you add

    if item.get("no.") then begin
    if (type = type::item) and (Item."item tracking no." <>'')
    then "Item Tracking Required" := true
    else "Item Tracking Required" := false;
    end;
Sign In or Register to comment.