Records shown in Form

keiahkeiah Member Posts: 9
edited 2005-02-16 in Navision Attain
My problem is the need to show only specific records from a table in a form (similar to reports, currreport.showoutput). :(

I generated a form based on table 5409 (prod order routing line). Now I only will show records in the form, which are based on a production order with status "released".

I tried in the OnAfterGetRecord() trigger in the new form:

ProductionOrder.RESET;
ProductionOrder.SETCURRENTKEY(Status, "No.");
ProductionOrder.SETRANGE(Status, Status::Released);
ProductionOrder.SETRANGE("No.","Prod. Order No.");
IF NOT ProductionOrder.FIND THEN EXIT;

but always all records of the table 5409 are shown.

Any hints how to supress records in forms without an additional table? :-k
Kai Huegle
from mack-rides.com

Comments

  • alanperualanperu Member Posts: 23
    HI,

    The easiest way around this is to add a flowfield to Table 5409 that is a simple lookup to the Status field in the Production Order table (linked by No.).

    Then you can just do a simple setrange on open form.

    e.g.

    SETRANGE(StatusLookup,StatusLookup::Released);

    You will just need to add the new StatusLookup field to the CalcFields on the Form properties.

    This should work.

    The only other option I can think of would be to mark the records using your existing OnAfterGetRecord code.

    It would need to look something like this:

    ProductionOrder.RESET;
    ProductionOrder.SETCURRENTKEY(Status, "No.");
    ProductionOrder.SETRANGE(Status, Status::Released);
    ProductionOrder.SETRANGE("No.","Prod. Order No.");
    IF ProductionOrder.FIND THEN
    MARK(TRUE);

    MARKEDONLY(TRUE);

    The only problem with this solution is that the MARKEDONLY(TRUE) line is within the OnAfterGetRecord trigger so it will be executed for each record. I can't think of another trigger to use off the top of my head, but you might be able to play around with it so that it is only called once (after all the records have been marked).

    Hope this helps!
  • keiahkeiah Member Posts: 9
    Hi,

    thx for your help, I tried first solution and it works fine. \:D/

    I just tried your second solution as well, but seems as it doesn't work as I implemented. I will try it again next days.

    Thx a lot for your help! :D

    Kai
    Kai Huegle
    from mack-rides.com
Sign In or Register to comment.