Onaftergetrecord

PeterGouwPeterGouw Member Posts: 4
Dear All,
I have these script below in Onaftergetrecord, but the message are appear after all record has completely processed.
Any suggestion why it is happened?

====================================================================
Window.UPDATE(1,"No.");

gVar_Skip := FALSE;

// Validation
gRec_SL.SETRANGE(gRec_SL."Document No.", "No.");
gRec_SL.SETRANGE(gRec_SL.Type, gRec_SL.Type::Item);
IF gRec_SL.FINDFIRST THEN
BEGIN
REPEAT
IF (gRec_SL.Quantity > 0) THEN
BEGIN
IF gRec_SL."Quantity Invoiced" = gRec_SL.Quantity THEN
BEGIN
// only for Released SO
IF Status <> Status::Released THEN
BEGIN
MESSAGE('Status SO %1 bukan Released!',"No.");
gVar_Skip := TRUE; // 2 april 2015
END;
// only for Released SO
END;
END;
UNTIL gRec_SL.NEXT = 0;
END; // Validation

IF gVar_Skip = FALSE THEN
BEGIN
///
/// PROCESSES IF VALID
/// PROCESSES IF VALID
///
END

Comments

  • neilgfneilgf Member Posts: 148
    Hi,

    What are you using this code on? Form, page or report?

    Also try and avoid nested begin end statements so you could replace

    {
    IF (gRec_SL.Quantity > 0) THEN BEGIN
    IF gRec_SL."Quantity Invoiced" = gRec_SL.Quantity THEN BEGIN
    // only for Released SO
    IF Status <> Status::Released THEN BEGIN
    MESSAGE('Status SO %1 bukan Released!',"No.");
    gVar_Skip := TRUE; // 2 april 2015
    END;
    // only for Released SO
    END;
    END;
    }

    with

    if (gRec_SL.Quantity > 0) and (gRec_SL."Quantity Invoiced" = gRec_SL.Quantity) and
    (Status <> Status::Released) then begin
    MESSAGE('Status SO %1 bukan Released!',"No.");
    gVar_Skip := TRUE; // 2 april 2015
    end else gVar_Skip := false;

    Neil
  • PeterGouwPeterGouw Member Posts: 4
    I am using report object for this process.
  • neilgfneilgf Member Posts: 148
    Hi,

    Then that's the issue as identified by Luc re message displayed at the end of the report processing data.
    Presume you do not want the message really so why not add a counter instead and display the count at the end to confirm the process is working?

    Something like:


    Window.UPDATE(1,"No.");

    gVar_Skip := FALSE;

    //fpc090415
    clear(TrueCount);
    clear(FalseCount);
    //fpc090415

    // Validation
    gRec_SL.SETRANGE(gRec_SL."Document No.", "No.");
    gRec_SL.SETRANGE(gRec_SL.Type, gRec_SL.Type::Item);
    IF gRec_SL.FINDFIRST THEN BEGIN
    REPEAT
    if (gRec_SL.Quantity > 0) and (gRec_SL."Quantity Invoiced" = gRec_SL.Quantity) and
    (Status <> Status::Released) then begin
    //fpc090415
    //MESSAGE('Status SO %1 bukan Released!',"No.");
    //fpc090415
    gVar_Skip := TRUE; // 2 april 2015
    //fpc090415
    TrueCount:=TrueCount+1;
    //fpc090415
    end else begin
    gVar_Skip := false;
    //fpc090415
    FalseCount:=FalsCount+1;
    //fpc090415
    end;
    //fpc090415
    {
    IF (gRec_SL.Quantity > 0) THEN BEGIN
    IF gRec_SL."Quantity Invoiced" = gRec_SL.Quantity THEN BEGIN
    // only for Released SO
    IF Status <> Status::Released THEN BEGIN
    MESSAGE('Status SO %1 bukan Released!',"No.");
    gVar_Skip := TRUE; // 2 april 2015
    END;
    // only for Released SO
    END;
    END;
    }
    //fpc090415
    UNTIL gRec_SL.NEXT = 0;
    END; // Validation

    IF gVar_Skip = FALSE THEN
    BEGIN
    ///
    /// PROCESSES IF VALID
    /// PROCESSES IF VALID
    ///
    END

    Neil
  • PeterGouwPeterGouw Member Posts: 4
    Actually, we need the message to appear as soon as the record is read and processed.

    But, since it is the natural behavior of Navision, I suppose there is nothing I could do, is there?


    Many thanks to Luc and Neil.
  • neilgfneilgf Member Posts: 148
    Hi

    Sorry no.

    Neil
  • satbirsatbir Member Posts: 33
    You can use CONFIRM (have both Ok, Cancel do nothing) or make your own Form which can be opened instead of a message screen.
Sign In or Register to comment.