Skip to main content

Notifications

Announcements

No record found.

Service | Customer Service, Contact Center, Fie...
Suggested answer

Open PDF File from Notes Entity in a new window using JS

Posted on by 55

Hi,

I have a requirement where I want to open Pdf file attached in the notes entity in new window using JS.

Regards,

Shoaib Khan.

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Open PDF File from Notes Entity in a new window using JS

    Hi ShoaibKhan:

    Please try the following code. I create an onload event to test:

    function onLoad(executionContext){
    var formContext = executionContext.getFormContext();
    //your noteId
    var noteId = "{aedf1d1d-10c7-d38a-b40a-d47f83729910}";
    var result = Xrm.WebApi.retrieveRecord("annotation", noteId).then(
    function success(result) {
    var file = {fileContent:result.documentbody,fileName:result.filename,fileSize:result.filesize,mimeType:result.mimetype};
    Xrm.Navigation.openFile(file,{openMode:1})
    },
    function(error) {
    console.log(error.message);
    }
    );
    }

    P.S. There is something wrong with Insert Code, so I directly paste here.

    It would open a new window to show it:

    pastedimage1635921987428v1.png

    Reference:

    docs.microsoft.com/.../openfile

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans