The operation could not complete because a record in the job queue entry table was locked by another user. Please retry the activity in NAV 2018

Hi Team

I experienced the above error, I wrote this below code in a codeunit

//Number of users = 4/ Four
ImprestHeader.CALCFIELDS("Pending Approvals");
IF (ImprestHeader."Pending Approvals" = 4) AND (ImprestHeader."Request Status" = ImprestHeader."Request Status"::"Pending Approval") THEN BEGIN
  Approval.RESET;
  Approval.SETRANGE("Table ID",52121500);
  Approval.SETRANGE("Document No.",ImprestHeader."No.");
  IF Approval.FINDFIRST THEN BEGIN REPEAT
    IF (Approval."Sequence No." = 1) AND (Approval.Status = Approval.Status::Open) THEN
      Approval.VALIDATE(Status,Approval.Status::Canceled);
    Approval.MODIFY;
  UNTIL Approval.NEXT = 0;
  END;
END;

//Number of users = 1/ One
ImprestHeader.CALCFIELDS("Pending Approvals");
IF (ImprestHeader."Pending Approvals" = 1) AND (ImprestHeader."Request Status" = ImprestHeader."Request Status"::"Pending Approval") THEN BEGIN
  Approval.RESET;
  Approval.SETRANGE("Table ID",52121500);
  Approval.SETRANGE("Document No.",ImprestHeader."No.");
  IF Approval.FINDFIRST THEN BEGIN REPEAT
      IF (Approval."Sequence No." = 3) AND (Approval.Status = Approval.Status::Open) THEN
      Approval.VALIDATE(Status,Approval.Status::Canceled);
    Approval.MODIFY;
    UNTIL Approval.NEXT = 0;
    END;
END;

//Number of users = 1/ One
ImprestHeader.CALCFIELDS("Pending Approvals");
IF (ImprestHeader."Pending Approvals" = 1) AND (ImprestHeader."Request Status" = ImprestHeader."Request Status"::Released) THEN BEGIN
  Approval.RESET;
  Approval.SETRANGE("Table ID",52121500);
  Approval.SETRANGE("Document No.",ImprestHeader."No.");
  IF Approval.FINDFIRST THEN BEGIN REPEAT
      IF (Approval."Sequence No." = 3) AND (Approval.Status = Approval.Status::Open) THEN
      Approval.VALIDATE(Status,Approval.Status::Canceled);
    Approval.MODIFY;
    UNTIL Approval.NEXT = 0;
    END;
END;

//Approve
ImprestHeader.CALCFIELDS("Pending Approvals");
IF (ImprestHeader."Pending Approvals" = 0) AND (ImprestHeader."Request Status" = ImprestHeader."Request Status"::"Pending Approval") THEN BEGIN
  ImprestHeader."Request Status" := ImprestHeader."Request Status"::Released;
  ImprestHeader.MODIFY;
END;
COMMIT;

This code on a report 

CleanedApprovals.ImprestDocument("Imprest Header");
COMMIT;

After run it, it worked yesterday but today it was showing the above error message.

Parents
No Data
Reply Children
No Data
Related
Recommended