Setting Filter in the OnPreDataItem gives error

tompynationtompynation Member Posts: 398
Hi, i modified the Report 7321 Inventory Movement...

I added an extra DataItem, it's a custom Record 'Packing Line'

DataItem Name
Item Journal Batch <Item Journal Batch>
Item Journal Line <Item Journal Line>
Packing Line <Packing Line>

I added 2 extra sessions at the bottom of the Report:
1. a Packing Line Header
2. a Packing Line Body

In the OnPreDataItem, i try to set the filter on the Packing Line record like the following:
Packing Line - OnPreDataItem()
IF ((gv_DocNo <> '') AND (gv_SourceNo <> '')) THEN BEGIN
  lv_ProdOrder.RESET;
  lv_ProdOrder.SETRANGE("No.",gv_DocNo);
  IF lv_ProdOrder.FINDFIRST THEN BEGIN

      lv_SalesOrder.GET(lv_ProdOrder."Sales Order");
      IF lv_SalesOrder."Linked Packing Order" <> '' THEN BEGIN
        "Packing Line".SETRANGE("Document No.",lv_ProdOrder."Sales Order");
        "Packing Line".SETRANGE("No.",gv_SourceNo);
      END;

  END;
END;

Problem is that this IF lv_ProdOrder.FINDFIRST THEN BEGIN is giving me the following error:
The expression Code cannot be type-converted to a Option value ](*,) :?: ](*,)

Does anyone can explain me from where this error is comming from??

When i remove this code, and add the 2 filters manually, then it works just fine

Answers

  • MatStephensSandAMatStephensSandA Member Posts: 74
    Hi.

    the issue is that you are doing a GET on a table that has more than one field in its primary key.
    If you design the table and look at the keys you will see that the 1st one has more than one field.
    So when performing a GET you have to decare all the fields in the primary key.

    hope this helps

    M@
    M@
    I have seen the future and it's egg shaped.
  • tompynationtompynation Member Posts: 398
    ](*,) Stupid of me...

    I would have seen the fault if the debugger would have given me the correct line where the error occured

    Anyway, thank you verry much
Sign In or Register to comment.