SETSELECTIONFILTER sends empty record

I'm using Dynamics nav 2009 R2. I have 2 forms Clients and Invoice Header.
In my Invoice Header table i have a field named "Clientid" and "payment date".
Right now i have this code on my ClientId OnAfterValidate() trigger
InvoiceHeaderFacturatie.GET;
MESSAGE(FORMAT(ClientId));
CurrForm.SETSELECTIONFILTER(InvoiceHeaderFacturatie);

And on my payment date field i have a CodeUnit on the OnActivate() trigger with the following code.
PaymentDate.PDTable(InvoiceHeaderFacturatie);

And here the code in the CodeUnit is
MESSAGE(FORMAT(pInvoiceHeaderFacturatie.ClientId));

When i pick a ClientId a message shows the right ClientId number but when i go the payment date its just show 0.

Answers

  • vaprogvaprog Member Posts: 1,144
    Hi Alex

    SETSELECTIONFILTER sets a filter such that when you iterate over the record, you will visit all records that were selected in the form. It does not alter any fields.

    Try this code in your Codeunit
    IF pInvoiceHeaderFacturatie.FINDSET THEN
      REPEAT
        MESSAGE(FORMAT(pInvoiceHeaderFacturatie.ClientId));
      UNTIL pInvoiceHeaderFacturatie.NEXT = 0;
    

    If you intended to get the current record only try
    pInvoiceHeaderFacturatie := Rec;
    

    Btw. what is
    InvoiceHeaderFacturatie.GET;
    
    supposed to do? If this is a setup table with only one record, SETSELECTIONFILTER does not make any sense at all, otherwise the GET without any primary key values probably does not make much sense.
  • RockWithNAVRockWithNAV Member Posts: 1,139
    SETSELECTIONFILTER works on how much record set you have selected.
Sign In or Register to comment.