Get last record stopped record

I have this dataport in nav 2009 and for new records in Sales Price table it isn't filling the field "Ending Date". I've the code (Findfirst) to that and with my debug it doens't enter there, even with a record

kd38g91zu6b8.png

Sales Price - OnAfterImportRecord()
"Sales Price".SETRANGE("Sales Price"."Item No.",PRODUTO);
"Sales Price".SETRANGE("Sales Price"."Sales Type",1);
"Sales Price".SETRANGE("Sales Price"."Sales Code",'ALL');
"Sales Price".SETRANGE("Starting Date",DATAINI);
"Sales Price".SETRANGE("Currency Code",'');
"Sales Price".SETRANGE("Variant Code",'');
"Sales Price".SETRANGE("Unit of Measure Code",'');
"Sales Price".SETRANGE("Minimum Quantity",QT);
"Sales Price".DELETEALL;

"Sales Price".RESET;
"Sales Price".SETRANGE("Sales Price"."Item No.",PRODUTO);
"Sales Price".SETRANGE("Sales Price"."Sales Type",1);
"Sales Price".SETRANGE("Sales Price"."Sales Code",'ALL');
"Sales Price".SETRANGE("Ending Date",0D);
"Sales Price".SETRANGE("Currency Code",'');
"Sales Price".SETRANGE("Variant Code",'');
"Sales Price".SETRANGE("Unit of Measure Code",'');
"Sales Price".SETRANGE("Minimum Quantity",QT);

IF "Sales Price".FINDFIRST THEN BEGIN
IF DATAINI< "Sales Price"."Starting Date" THEN
"Sales Price".DELETEALL;
END;


"Sales Price".RESET;
"Sales Price".SETRANGE("Sales Price"."Item No.",PRODUTO);
"Sales Price".SETRANGE("Sales Price"."Sales Type",1);
"Sales Price".SETRANGE("Sales Price"."Sales Code",'ALL');
"Sales Price".SETRANGE("Ending Date",0D);
"Sales Price".SETRANGE("Currency Code",'');
"Sales Price".SETRANGE("Variant Code",'');
"Sales Price".SETRANGE("Unit of Measure Code",'');
"Sales Price".SETRANGE("Minimum Quantity",QT);

IF "Sales Price".FINDFIRST THEN BEGIN
"Sales Price"."Ending Date":=DATAINI-1;
MODIFY;
END;

"Sales Price".RESET;
"Sales Price"."User ID":=USERID;
"Sales Price"."Data criacao":=TODAY;
"Sales Price"."Ending Date":=0D;
"Sales Price"."Sales Type":=1;
VALIDATE("Sales Code",'ALL');
"Item No.":=PRODUTO;
"Starting Date":=DATAINI;
"Minimum Quantity":=QT;
"Sales Price"."Allow Invoice Disc." :=TRUE;
"Sales Price"."VAT Bus. Posting Gr. (Price)":='NAC';
"Sales Price"."Allow Invoice Disc.":=TRUE;


VALIDATE("Unit Price",PVP);

// "Sales Price".INSERT;

My text file

1510300131 06-11-18 0 4,66

(itemno, starting date, quantity, price)







I've also tried this in OnInsert Sales Price trigger


IF xRec."Item No."<>'' THEN BEGIN
Rec."Ending Date":=xRec."Starting Date"-1;
MODIFY;
END;

Answers

  • krikikriki Posts: 8,570Member, Moderator
    [Topic closed because of double posting]
    See https://forum.mibuso.com/discussion/72500
    This topic will be deleted after a week.

    Regards,Alain Krikilion
    Use the SEARCH,Luke! || No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
    NAV TechDays 2018: 22 & 23 November 2018, Antwerp (Belgium)
This discussion has been closed.