In my restendpoint.js file, I have a function called retrieveRecord which is defined on this website
I am working on a function that should trigger whenever the Programme (a lookup field) on the Application entity changes. The goal is to fetch the attributes of the Programme record.
I'm unsure about what the correct oDataSetName should be for this operation.
The Display Name of the entity is Programme and its actual name is ntt_programme.
I have experimented with using both ProgrammeSet and ntt_ProgrammeSet as oDataSetNames, but so far, every AJAX call has ended up in the failure callback method, resulting in an alert saying In ProgrammeErrorCallBack
.
- Why does the call keep failing?
- What exactly should the oDataSetName be, and where is it typically stored in CRM - is it always EntityName followed by Set?
I am feeling a bit lost here since I am relatively new to JS / AJAX / REST / JSON!
ProgrammeOnChange: function () {
var programmeLookup = Xrm.Page.getAttribute("new_programmeid").getValue();
if (programmeLookup != null && programmeLookup[0] && programmeLookup[0].name != null) {
var programmeId = programmeLookup[0].id;
alert(programmeId);
var oDataSetName = "ProgrammeSet";
CRM2011Common.Functions.retrieveRecord(programmeId, oDataSetName, CRM2011.Application.ProgrammeSuccessCallBack, CRM2011.Application.ProgrammeErrorCallBack);
}
},
ProgrammeSuccessCallBack: function (result) {
alert("In ProgrammeSuccessCallBack");
var programme = result;
alert(programme.new_name);
},
ProgrammeErrorCallBack: function (XmlHttpRequest, textStatus, errorThrown) {
alert("In ProgrammeErrorCallBack");
alert('Error retrieving Programme: ' + textStatus + ' ' + errorThrown);
}