Hello,
I am new to Microsoft CRM customizations, and I have a couple of questions regarding a customization that I am trying. What I am doing is getting the latest note from the account entity field, and placing it in a text field I have added in the proposal entity which is related to the account entity. Earlier, I had received a response on getting the latest note by using the REST API. I am also working in Microsoft Dynamics CRM 2011.
1) According to my research, to use the REST api, I have to add the appropriate form libraries. In order to use the script which is using the REST API, which libraries must I add, and where can I get them?
2) Since I have the function in which I get the latest value from the note field in the account entity, how can I use this to set the latest note in the text field of the proposal entity. Would I have to create a new function? What would I pass as the set value?
This is the code that was posted earlier to get the latest note
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 { alert("Error"); }
}
};
req.send();
}
I have been researching, but there isn't very much out there that is tailored towards newcomers. If anyone could help me with this, or point me in the right direction, it would be greatly appreciated. Thank you!