OnRun() WITH QueueLines DO BEGIN IF FINDSET THEN BEGIN repeat success := TryPostDocument(GUID); WriteLog(GUID,success); until next = 0; END; END; TryPostDocument(pGUID : GUID) Importline.GET(pGUID); //<--- If not get the function return correctly "FALSE" and writes some logs in 'WriteLog' . . . WITH GenJournalLine DO BEGIN INIT; "Line No." := 1; VALIDATE("Account Type",GenJournalLine."Account Type"::Customer); VALIDATE("Account No.",Importline.Customer); VALIDATE("Document Type",GenJournalLine."Document Type"::"Credit Memo"); VALIDATE("Posting Date", Importline."Posting Date"); "Journal Template Name" := Template; "Journal Batch Name" := Name; VALIDATE("Document No.",DocumentNo); Description := Importline.Description; VALIDATE("Credit Amount", Importline.Amount); INSERT; INIT; "Line No." := 1; VALIDATE("Account Type",GenJournalLine."Account Type"::"G/L Account"); VALIDATE("Account No.",10000); VALIDATE("Document Type",GenJournalLine."Document Type"::"Credit Memo"); VALIDATE("Posting Date", Importline."Posting Date"); "Journal Template Name" := Template; "Journal Batch Name" := Name; VALIDATE("Document No.",DocumentNo); Description := Importline.Description; VALIDATE("Debit Amount", Importline.Amount); INSERT; //<---- Error cause the same Line No, The function do not return anything, but the Job Queue stops... END;
IF NOT INSERT THEN ERROR(GETLASTERRORTEXT);
Answers
Are you saying that [WriteLog(GUID,success)] is not happening when [TryPostDocument(GUID);] returns false?
Or are you saying that [TryPostDocument(GUID);] never returns false?
(JobQueue does not need a critical error to stop (i believe), it could simply be reading the last errortext and decide to stop.)
(ps. Try functions are not recommended for complex code or data writing code without safeguards - read Vjeko's blogs for that)
Good luck.
What do you mean with a safeguard for try functions?
Edit:
Hmm ok sems to be crazy shit this 'try-functions' in NAV. Realy what did MS excpected when they implemented it? Its only usable if the transaction was rolle backed...
Thanks Peter+is1 !