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 511

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

  • Hein Kruger Profile Picture
    511 on at
    RE: BC 20 pdfdocuments API missing

    Thank you ZHU,

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

  • Suggested answer
    Hein Kruger Profile Picture
    511 on at
    RE: BC 20 pdfdocuments API missing

    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

  • Suggested answer
    YUN ZHU Profile Picture
    81,785 Super User 2025 Season 1 on at
    RE: BC 20 pdfdocuments API missing

    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

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 294,261 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 233,011 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans