web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Answered

BC 20 pdfdocuments API missing

(0) ShareShare
ReportReport
Posted on by 629

Hi we have an onprem BC20 customer. 
We need to use the pdfDocuments API. When looking at the available API web Services on Table = 2000000193 we cannot see the PDFdocument page. 

Ons BC18 and BC20 on prem we can see the pdfdocument page (ID 30056) is exposed. 
pastedimage1681906221648v1.png

But on our BC20 onprem version there is no pdfDocument page. 
How can we add/install the pdf document?
pastedimage1681906343705v2.png

Also I noticed there is only beta version API on the cliens webservice. How van I add the API v2.0?
pastedimage1681906478811v1.png

Thanks

I have the same question (0)
  • Suggested answer
    YUN ZHU Profile Picture
    95,729 Super User 2025 Season 2 on at

    Hi, You can use the following method to find the code of this API, then copy it to your Extension, change the ID, and publish. (Might need to do some code upgrades)

    https://yzhums.com/20960/

    Source Code: https://github.com/microsoft/ALAppExtensions/blob/a197282b172c023f88711310947deb5c78b0a393/Apps/W1/APIV2/app/src/pages/APIV2PDFDocument.Page.al

    page 30056 "APIV2 - PDF Document"
    {
        APIVersion = 'v2.0';
        EntityCaption = 'PDF Document';
        EntitySetCaption = 'PDF Document';
        DeleteAllowed = false;
        Editable = false;
        InsertAllowed = false;
        ModifyAllowed = false;
        DelayedInsert = true;
        EntityName = 'pdfDocument';
        EntitySetName = 'pdfDocument';
        ODataKeyFields = Id;
        PageType = API;
        SourceTable = "Attachment Entity Buffer";
        SourceTableTemporary = true;
    
        layout
        {
            area(content)
            {
                repeater(Group)
                {
                    field(id; Id)
                    {
                        Caption = 'Id';
                        Editable = false;
                    }
                    field(parentId; "Document Id")
                    {
                        Caption = 'Parent Id';
                        Editable = false;
                    }
                    field(parentType; "Document Type")
                    {
                        Caption = 'Parent Type';
                        Editable = false;
                    }
                    field(pdfDocumentContent; Content)
                    {
                        Caption = 'PDF Document Content';
                        Editable = false;
                    }
                }
            }
        }
    
        actions
        {
        }
    
        trigger OnFindRecord(Which: Text): Boolean
        var
            PDFDocumentManagement: Codeunit "PDF Document Management";
            DocumentType: Enum "Attachment Entity Buffer Document Type";
            DocumentId: Guid;
            FilterView: Text;
            DocumentIdFilter: Text;
            DocumentTypeFilter: Text;
            IdFilter: Text;
        begin
            if not PdfGenerated then begin
                FilterView := GetView();
                DocumentIdFilter := GetFilter("Document Id");
                DocumentTypeFilter := GetFilter("Document Type");
                IdFilter := GetFilter(Id);
                if (DocumentIdFilter <> '') and (IdFilter <> '') and (LowerCase(DocumentIdFilter) <> LowerCase(IdFilter)) then
                    Error(ConflictingIdsErr, DocumentIdFilter, IdFilter);
                if (DocumentTypeFilter = '') then
                    Error(MissingParentTypeErr);
                if (DocumentIdFilter = '') then
                    if (IdFilter = '') then
                        Error(MissingParentIdErr)
                    else
                        DocumentIdFilter := IdFilter
                else
                    IdFilter := DocumentIdFilter;
    
                DocumentId := Format(DocumentIdFilter);
                Evaluate(DocumentType, DocumentTypeFilter);
                SetView(FilterView);
                if IsNullGuid(DocumentId) then
                    exit(false);
                PdfGenerated := PDFDocumentManagement.GeneratePdfBlobWithDocumentType(DocumentId, DocumentType, Rec);
            end;
            exit(true);
        end;
    
        var
            PdfGenerated: Boolean;
            ConflictingIdsErr: Label 'You have specified conflicting identifiers: %1 and %2.', Comment = '%1 - a GUID, %2 - a GUID';
            MissingParentIdErr: Label 'You must specify a parentId in the request body.', Comment = 'parentId is a field name and should not be translated.';
            MissingParentTypeErr: Label 'You must specify a parentType in the request body.', Comment = 'parentType is a field name and should not be translated.';
    }

    Hope this helps.

    Thanks.

    ZHU

  • Suggested answer
    Hein Kruger Profile Picture
    629 on at

    For some Reason. APIV2 extension wasn't installed.

    Here is the weird part. The extensions for API are not shown in extension management.

    We got the Microsoft__Exclude_APIV2_.app file from the onPrem download file.

    ..\Dynamics.365.BC.38230.W1.DVD\Applications\APIV2\Source

    After Publishing and installing V2.0 was available on the web service Table =  2000000193

  • Hein Kruger Profile Picture
    629 on at

    Thank you ZHU,

    Although I didn't use your answer. It did lead me to the correct way.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,135

#2
YUN ZHU Profile Picture

YUN ZHU 733 Super User 2025 Season 2

#3
Sumit Singh Profile Picture

Sumit Singh 612

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans