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 :
Microsoft Dynamics CRM (Archived)

Getting the Value of the note field from the Account Entity

(0) ShareShare
ReportReport
Posted on by

Hello,

 

I was wondering how I could get the value of the note field from the account entity using javascript. Ultimately, what I am trying to do is get the latest note from the account field, and add it to a text field I have added in the Proposal entity. Any help with this would be greatly appreciated. Thanks in advance!

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Royal King Profile Picture
    27,686 on at

    You have to use either REST or SOAP API to get the latest note of an account record.

    below script will get the latest note added on the account record

    function GetLatestNote() {

       //OData URI to get address information from parent account record

       var oDataURI = Xrm.Page.context.getClientUrl()

           + "/XRMServices/2011/OrganizationData.svc/"

           + "AnnotationSet?$select=FileName,NoteText,Subject&$orderby=CreatedOn desc&$top=1&$filter=ObjectId/Id eq guid'"+Xrm.Page.data.entity.getId()+"' and ObjectTypeCode eq 1";

       //Asynchronous XMLHttpRequest to retrieve account record

       var req = new XMLHttpRequest();

       req.open("GET", encodeURI(oDataURI), true);

       req.setRequestHeader("Accept", "application/json");

       req.setRequestHeader("Content-Type", "application/json; charset=utf-8");

       req.onreadystatechange = function () {

           //debugger;

           if (this.readyState == 4 /* complete */) {

               req.onreadystatechange = null; //avoids memory leaks

               if (this.status == 200) {

                   //parse the response string as a JSON object into the successCallback method.

                   var note = (JSON.parse(this.responseText).d);

                   if(note != null )

                   {

                       var notetext  =note[0].NoteText;

                   }

               }

               else {

                  aler("eeror");

               }

           }

       };

       req.send();

    }

  • Community Member Profile Picture
    on at

    Thank you for the response!

    I am relatively new to customizations in CRM with javascript, so I would like to ask, would I just have to add the function to the event handler, and that's it? The guides I have been following mention clicking on the field and adding the function under the events tab in the field properties, but that is not the case with the notes.

  • Verified answer
    Royal King Profile Picture
    27,686 on at

    check the below post that provides detail information about adding javascript to Form

    www.dynamicscrmpros.com/getting-started-with-javascript-form-scripting-for-microsoft-dynamics-crm-2011

  • Community Member Profile Picture
    on at

    Thank you very much for the help! It was greatly appreciated :)

  • Community Member Profile Picture
    on at

    I'm wondering if you are still here? I have come back to working on this, and when I try to save, I am getting an error message. I found that it is not reading the note value, and is returning null. Any help would be greatly appreciated!

  • Community Member Profile Picture
    on at

    Alright, so I have found out why it is returning null. It is because I cannot hook the function to the notes field directly. I thought that by just hooking the event to the notes and activities section it would work, but that is not the case. If anyone could suggest how I could work around that, that would be great!

  • Royal King Profile Picture
    27,686 on at

    You have to attach JavaScript function call to the Account form onload event.

  • Community Member Profile Picture
    on at

    I attached the javascript function call to the Account form, but I am still getting a null value. It is the GetLastNote function that I attach is that correct?

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 > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans