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 :
Service | Customer Service, Contact Center, Fie...
Suggested Answer

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

(0) ShareShare
ReportReport
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.

I have the same question (0)
  • Suggested answer
    Community Member Profile Picture
    on at

    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

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 > Service | Customer Service, Contact Center, Field Service, Guides

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 60 Super User 2025 Season 2

#2
Siv Sagar Profile Picture

Siv Sagar 52 Super User 2025 Season 2

#3
Daniyal Khaleel Profile Picture

Daniyal Khaleel 36 Most Valuable Professional

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans