What is the process for retrieving document field values for an item in Umbraco 7 backoffice?

I have developed a unique Umbraco 7 dashboard where I aim to retrieve specific field details from instances of a particular document type in my Umbraco CMS.

After successfully obtaining a list of all documents of the specified type using

entityResource.getChildren(1386, "Document")
, I then proceed to call
entityResource.getById(item.id, "Document")
for each document. While I can view many details for each document instance, I am unable to access the data entered by the editor during creation. How can I retrieve this information utilizing Umbraco's Angular services/API?

Here is a snippet of the code within the dashboard:

// fetching community alerts
entityResource.getChildren(1386, "Document")
    .then(function (ent)
    {
        angular.forEach(ent, function (item)
        {
            let communityalert = {
                umbracoItem: item,
                title: '',     // Data from each document will be placed here
                topic: ''
            };
            entityResource
                .getById(item.id, "Document")
                .then(function (entity)
                {
                    console.log('entity', entity);
                    communityalert.title = entity.name;
                    communityalert.umbracoItem = entity;

                    entityResource
                        .getUrl(item.id, "Document")
                        .then(function (url)
                        {
                            communityalert.url = url;

                            // Finally, add collected data to VM.
                            vm.CommunityAlerts.push(communityalert);
                        });
                });
        });
    });

Answer №1

After thorough investigation, I finally discovered the solution: utilize the injectable contentResource's getById() method. This method retrieves all the details of a content item, as opposed to the entityResource's getById() method which only retrieves common details for a content tree. The latter resource's methods provide all the details of a content item, including entered field data.

contentResource.getById(item.id)
    .then((data) =>
    {
        //console.log('contentResource.getById data', data);
        angular.forEach(data.properties, (property) =>
        {
            //perform actions with the document's content...
        });
    });

In summary, use methods from the injectable resource entityResource to obtain a subset of details, but if you require all the details of a document, utilize the injectable contentResource resource.

It becomes straightforward once you spend enough time reading the documentation!

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

A Sweet Alert to Deliver your Morning Toasty Message

I seem to be encountering an issue with my toast message. Instead of the toast popping up immediately after submitting the form, it keeps appearing even if I haven't submitted the form and even when navigating from another page to this one, the toast ...

Learn how to display a web page in a tab view similar to the toggle device toolbar option

Is it possible to simulate the toggle device toolbar of a web page using JavaScript? https://i.stack.imgur.com/M9oB0.png For example, can we set up a webpage to always display in tab or mobile view like on YouTube? ...

What is the best way to automatically create a list of file names that can be used in a Grunt task?

I am currently utilizing load-grunt-config and grunt-prompt for my project development. I am working on an init task that involves moving php templates between folders. At the moment, I have hardcoded the template filenames, but I would prefer if Grunt co ...

Combine the remaining bars by stacking the highest one on top in Highchart

Making use of stacking to display the highest value as the longest column/bar, with smaller values being merged within the highest one, can create a more visually appealing stack chart. For example, when looking at Arsenal with values of 14 and 3, ideally ...

Creating and managing temporary users in MEAN Stack without requiring login or signup

Currently in the process of creating a website related to Bitcoin! The concept is as follows: When a user lands on the page, they will see a balance of 0.000BTC along with a deposit address. Upon depositing funds to that address, it will be displayed af ...

Is there a way to determine the color of an element when it is in a hover state?

I recently started using the Chosen plugin and noticed that the color for the :hover on the <li> elements is a bright blue. I want to change it to a bold red color instead. https://i.stack.imgur.com/mcdHY.png After inspecting it with the Chrome too ...

Utilizing Ajax for Dynamically Filling a Dropdown Menu

My journey into the world of Ajax has led me to a state of confusion and frustration. The task at hand is to populate the first box with customer data from the database, then use the customerID to retrieve all vehicleID's using the select.php script. ...

Is it possible to modify CSS properties by clicking on buttons?

Hello, I really need help with this task. I want to change the style of a button (which is actually a link) by clicking on it. These buttons are housed within a dynamic child div that changes each time, but the name of the dynamic child div remains con ...

Having trouble with installing a React app using npx create-react-app my-app?

description needed for image Having trouble creating a react application using npx create-react-app my-app... Encountering errors shown in the image. Attempted npm init but it was unsuccessful. Included node.js and vs code in the path. ...

Uploading a file with AngularJS and storing it in a database

I have been attempting to implement ngFileUpload in order to upload images and store them in a database – specifically, a mongoLab database that accepts JSON objects which can be posted using this syntax: $http.post('myMongoName/myDb/myCollection/ ...

Employing eval for parsing the JSON data

function ajaxFunction(){ var ajaxRequest; // The variable that enables the use of Ajax technology! try{ // Compatible with Opera 8.0+, Firefox, and Safari ajaxRequest = new XMLHttpRequest(); } catch (e){ // For Internet Explorer Browsers ...

Is the Javascript Browser Plugin currently activated?

I am currently experimenting with Google Earth and I'm trying to figure out whether the Browser Plugin for Google Earth is Enabled or not (Please note: Scenarios such as the Plugin being installed but deactivated). This is my plan on how to achieve t ...

Ways to update div using jquery without creating copies

I have a code snippet that refreshes a div every 10 seconds: <script type="text/javascript> setInterval(function(){ $('#feed').load('forum.php #feed').fadeIn("slow"); }, 10000); </script> It works well, but there is one is ...

Error: Attempting to access the 'toString' property of an undefined object is not permitted (apex-charts)

While working on a personal project, I considered using apexcharts. However, an error shown in the image kept popping up. It seemed to disappear when I set the width and height properties in the Chart component or when the site was in production. Currently ...

Add multiple checkboxes in a dropdown menu to save in a MySQL database

I have a register.php and I'm trying to insert the data into users table. The problem I have is with "languages" field - I've created a dropdown list with multiple checkboxs. I want the user of course to be able to insert to his profile more tha ...

Apply a class to the input element within an ng input tag

When working with ng-input-tag, I tried to apply a bootstrap class to the input element of HTML in order to utilize specific bootstrap styles. Unfortunately, it did not work as expected. Below you can find the code snippet: angular .module('m ...

resolve problems with Jquery scripts

Having some issues with importing a script from another file in jQuery. I have tried using $.getScript and $.ajax(); how can I incorporate a script like require.js in jQuery? util.js function getSessionInformation () { $.ajax({ url: '../contr ...

Why do I keep receiving the error message "Cannot set property of undefined"?

In the midst of a small project that involves utilizing nuxt, js, and axios, I encountered an issue when attempting to assign the response data to my formFields object. Despite having declared formFields within the data section, I kept receiving an error m ...

How can you interact between a parent's named controller and JavaScript files in AngularJS?

Lately, I've been exploring the use of named controllers in my code and find it to be a much better alternative to using traditional $scope variables. It makes accessing parent controller attributes and functions within the DOM seamless. See an exampl ...

Listen for incoming data from the client in the form of an ArrayBuffer

I have been utilizing the ws library within nodejs to develop a small cursor lobby where players can interact. I have managed to utilize the server to send ArrayBuffers with bit streams to the client and successfully decode them. However, I am encountering ...