IJL_ - Import::OnBeforeInsertRecord()
IJL1.RESET;
IJL1.SETRANGE("Journal Template Name",'PHYS. INVE' );
IJL1.SETRANGE("Journal Batch Name",BatchName);
IJL1.SETRANGE("Source Code",'PHYSINVJNL');
IF IJL1.FINDLAST THEN BEGIN
LineNo := IJL1."Line No.";
END;
LineNo += 10000;
IJL_.RESET;
WITH IJL_ DO BEGIN
IJL_."Journal Template Name" := 'PHYS. INVE';
IJL_."Journal Batch Name" := BatchName;
IJL_."Line No." := LineNo;
VALIDATE(IJL_."Item No.",ItemNo);
IJL_."Source Code" := 'PHYSINVJNL';
CLEAR(VarDate);
EVALUATE(VarDate,PostDate);
VALIDATE(IJL_."Posting Date",VarDate);
VALIDATE(IJL_."Entry Type",IJL_."Entry Type"::"Positive Adjmt.");
VALIDATE(IJL_.Description,Desc);
VALIDATE(IJL_."Location Code",Loc);
CLEAR(VarDec);
EVALUATE(VarDec,Qty);
VALIDATE(IJL_.Quantity,VarDec);
VALIDATE(IJL_."Unit of Measure Code",UOM);
IJL_.INSERT;
END;
Comments
In
And then it should work.
still got the same error.
debug also pointing to
"IF IJL1.FINDLAST THEN"
any other solution?
[-o<
if you ONLY have records with "Source Code" = 'PHYSINVJNL' then, don't filter it. Otherwise you will get the error that the line already exists, when you already have data without the filtered source code in your Journal Line, because it's not part of your primary key.
I would write your FINDLAST like this (but yours should work as well)
Check if you really assign the correct values, which you filter on, to your new record.
the table is absolutely empty. whatever field that i use for setrange, it doesn't really mattered.
and i use your code but still the same error.
i used the same code with a little modification so that i can run in dataport nav 2009(classic)
and its success with no error.
thanks i appreciate your help, but i think i have to close this thread in one week if no one reply this again
because i give up on this one.
(Because Line No. is the primary Key of the table)
thank you but still doesn't work.
same error
Try to delete it
thank you again but if i delete the "INSERT", microsoft dynamic nav is not responding and then crash
In this way you will be able to manage all the logic by C/AL code.
thank you but still...
i put all the C/AL code in OnPostXMLport trigger, but its like no code at all.
even if i just use "message('Test');"
nothing show up.
is this mean my Nav 2013 application have a problem?
thank you