Send Document Approval Problem

Need some help. Document Approval. I have created a new Document Type “Petty Cash” and configured all the tables and number series. Am able to create one but when I send for approval it gives an error “No Approval Template is enabled for Document Type Petty Cash” even though I have defined and enabled it on the tables. Where could I be going wrong?

Below is the code:

TestSetup;
WITH PurchaseHeader DO BEGIN
IF Status <> Status::Open THEN
EXIT(FALSE);

IF NOT ApprovalSetup.GET THEN
ERROR(Text004);

IF NOT PurchLinesExist THEN
ERROR(Text015,FORMAT(“Document Type”),“No.”);

// ERROR(STRSUBSTNO(Text129,PurchaseHeader.“Document Type”));
// *******************************************************************************************
TemplateRec.SETCURRENTKEY(“Table ID”,“Document Type”,Enabled);
TemplateRec.SETRANGE(“Table ID”,DATABASE::“Purchase Header”);
TemplateRec.SETRANGE(“Document Type”,“Document Type”);
TemplateRec.SETRANGE(Enabled,TRUE);
IF TemplateRec.FIND(’-’) THEN BEGIN
REPEAT
IF TemplateRec.“Limit Type” = TemplateRec.“Limit Type”::“Credit Limits” THEN BEGIN
ERROR(STRSUBSTNO(Text025,FORMAT(TemplateRec.“Limit Type”),FORMAT(“Document Type”),
“No.”));
END ELSE BEGIN
IF NOT FindApproverPurchase(PurchaseHeader,ApprovalSetup,TemplateRec) THEN
ERROR(Text010);
END;
UNTIL TemplateRec.NEXT = 0;
FinishApprovalEntryPurchase(PurchaseHeader,ApprovalSetup,MessageType);
CASE MessageType OF
MessageType::AutomaticPrePayment:MESSAGE(Text128,PurchaseHeader.“Document Type”,PurchaseHeader.“No.”);
MessageType::AutomaticRelease:MESSAGE(Text003,PurchaseHeader.“Document Type”,PurchaseHeader.“No.”);
MessageType::RequiresApproval: MESSAGE(Text001,“Document Type”,“No.”);
END;
END ELSE

ERROR(STRSUBSTNO(Text129,PurchaseHeader.“Document Type”));

END;

Have you defined the templates in Approval Templates table ??

Good day Amol,

I have defined the Document Type in the template and enabled it. I have also created additional approvers on the other table.

best regards,

Hi Musenga

I guess the problem is on the way you have defined the option string values. NAV will check based on position of the option and not the text.

My guess is that you just added the “Petty cash” direct on position 6 on (purchase header) while on Approval template is on position 7 , as shown below. Make sure the Petty Cash is on the same position (option string) for both tables.

Purchase Header:

Quote,Order,Invoice,Credit Memo,Blanket Order,Return Order,Petty Cash

Approval Templates:

Quote,Order,Invoice,Credit Memo,Blanket Order,Return Order,None,Petty Cash

Hi Archard,

Thanks for the help. The error has disappeared after making the two table options the same as suggested. I followed the Purchase Header format because it is the most common to other tables like Purchase Line etc. However, I get another error “You must import an Approval Template in Approval Setup”. My fear is am already using the current template for other approvals like quotes, orders etc. Any suggestions of how I deal with this without replacing the current setup.

I beleive that is the setup issue, the error means there is no EMAIL template saved on the approval setup table. You have to import the email template. Go to the “Aproval setup” form click Mail Templates->Approval Mail Template->Import

Thanks Archard,

I accidentally enabled the Emails Notifications. I unchecked the option and I was able to create the Entries. This has definitely solved my other problems as I look at Document Approval for other forms. Thanks a lot and cheers.

Best regards,

Musenga