Retrieval of entity through REST Endpoint using ODataSetName for Custom Entity

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.

  1. Why does the call keep failing?
  2. 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);
}

Answer №1

It seems like there might be a problem with the capitalization in your code. Make sure to use ntt_programmeSet, or something similar but with correct casing.

I suggest utilizing LinqPad to test out REST oData calls before implementing them. This will help you avoid any issues caused by incorrect casing. You can set up a new odata connection to the CRM SDK endpoint and then write a linq statement to retrieve the desired information. By clicking on the Lambda symbol, you'll receive the odata URL. Simply ensure that your javascript generates the exact same URL to prevent any errors.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

jqgrid now features inline editing, which allows for the posting of only the data that

My jqGrid includes editable columns, and I am looking for a way to only post the data of columns where changes have been made. Here is an example of my colModel: colModel: [{ name: 'I_PK', index: 'u.I_PK ...

Is it possible to efficiently transfer a Tensorflow.js Tensor between Node.js processes?

Currently, I am in the process of building an AI model using Tensorflow.js and Node.js. One of the challenges I am facing is handling a large dataset in a streaming manner due to its size being too massive to be stored in memory all at once. This task invo ...

Having difficulty getting AJAX to properly save data to WordPress database

Currently, I am working on developing a plugin for events that includes a comment section for each event. I have successfully implemented the functionality to save comments. However, I am encountering an issue where upon submission of the form, I am redire ...

Can an event be passed from one Vue.js component to another without relying on a global EventBus?

I have two independent components that are not directly related to each other. However, I want them to be able to communicate so that when an event is triggered in one component, the other component can respond accordingly. For example, let's conside ...

The anchor link is not aligning properly due to the fluctuating page width

Seeking help to resolve an issue I'm facing. Maybe someone out there has a solution? The layout consists of a content area on the left (default width=70%) and a menu area on the right (default width=30%). When scrolling down, the content area expand ...

Is it possible for the req.url path in expressjs to represent a different URL?

Recently, I discovered some suspicious requests being sent to my node-express server. In response, I created a middleware to record the request URLs. After logging these requests, I noticed that most of them started with '/', but there were also ...

Exploring a multitude of data within a hefty json log document using node.js

I am dealing with a JSON file named sensorlogs.json that contains data from different sensors transmitting at varying frequencies. The timestamps in the file are not in order and one sensor may have missing entries. The goal is to analyze each sensor&apos ...

submit information using AJAX with jQuery

My goal is to save data in a database when a button is clicked. However, I'm facing an issue where the code works in some browsers but not in Firefox. When I click the button, an empty alert pops up and the data is not saved in the table. $("#Sav ...

Does the String.replace() function in Javascript have the capability of incorporating line breaks?

Is it possible to use the String.replace() method in JavaScript to replace any character with a line feed symbol? For example: newString = oldString.replace(/x/, "linefeed character (\n)"). ...

Obtain the inner text input value using jQuery

In my form, there is a feature that adds a new row of text inputs dynamically when a user wants to add more rows. Each new row is automatically populated with input fields that have the same id and class as the previous ones. My question is: how can I re ...

Guide to enabling cross-domain uploads of files

After following a tutorial, I successfully implemented an HTML5 uploader on my website. The source of the tutorial can be found here: The uploader works perfectly; however, I am now facing an issue where I want to upload files to a different domain. Accor ...

What could be the reason that the results of my quick sort function are not appearing on the screen

I'm having trouble getting any output from this code. Can someone help me figure out what's wrong? function Ascending() { var array = new Array(); array[0]=parseInt(document.getElementById("1").value); array[1]=parseInt(document.getElementById(" ...

Loading a MySQL query using AJAX in a straightforward way

I previously mentioned this in another post but now I understand the question I want to ask. Is there a straightforward way to load 5 rows from a MySQL table and then use an AJAX button to display 5 more, similar to Facebook's 'View Older Posts& ...

When making an Ajax call to an ASP.NET MVC controller, the Access-Control-Allow-Origin error is commonly encountered

Currently, I am facing an issue with my ajax call in the view script. The problem arises when attempting to retrieve data from a controller action within the same website, resulting in a Cross-Origin error message. The JavaScript code snippet is as follow ...

Break up every word into its own separate <span>

I am currently facing an issue with displaying an array of strings in HTML using spans. These spans are wrapped inside a contenteditable div. The problem arises when a user tries to add new words, as the browser tends to add them to the nearest existing sp ...

Where should the webapp files for a Node.js application be located within the server directory?

Can someone help clarify a question I have been struggling with? I have created a nodejs webapp with a specific directory structure, as shown in the screenshot. This app will eventually incorporate MongoDB and store a large number of audio files. I am usi ...

Improvement in Select2 Change Event: Update the subsequent select2 box options based on the value change in the preceding select2 box

I need assistance with two select boxes, namely Category and Sub-category. My objective is to dynamically alter the available options in the subcategory box based upon the value selected in the category box. Additionally, I would like to load data for the ...

Deleting images from Firestore using a Vue.js componentReady to learn how to remove images

I recently came across a Vue.js image uploader component that I am trying to repurpose (https://codesandbox.io/s/219m6n7z3j). This component allows users to upload images to Firebase storage and save the downloadURL to firestore for continuous rendering of ...

Should I use an array literal or split a string?

Imagine you are in need of a predetermined list of words (the focus here is not on the debate surrounding hard-coding). Would you choose this approach: var items = 'apple banana cherry'.split(' '); Or do you favor this alternative: ...

limit mongoose search results to a specific year

Would it be possible to add an option for the api user to filter the wine query by year? However, if no year is specified, mongoose should not return an empty array. The same applies to the price property. For example, http://localhost:1234/api/wine?year= ...