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;
IF xRec."Item No."<>'' THEN BEGIN Rec."Ending Date":=xRec."Starting Date"-1; MODIFY; END;
Answers
I don't see if it's a date something like that could work. You should use calcdate instead:
https://docs.microsoft.com/en-us/dynamics-nav/calcdate-function--date-
... also, if the quantity scale changes, you might be in trouble. But it is a tricky business to import prices unless what you import replaces what you already have entirely.
I tried to put a message in the "find last" function but it doens't pop up for some reason, and in this specific produtct I have multiple Sales Line lines.
In the image below I have the text file i'm trying to import and the final result
The trigger you used, according to your first post, is ok (assuming that data item processes the import data).
So I need to remove all code from the dataport which don't exist in the text file? I'm confused