Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • ross Horsey 2 posts 72 karma points
    Dec 18, 2017 @ 15:49
    ross Horsey
    0

    contentResource.save not updating content

    Hi All,

    Hopefully this is not a stupid question but...

    I'm trying to update the children of an item when a property on my custom property editor is changed.

    I get as far as saving the item, and it comes back with a 200 response from the API, but the item is unchanged.

    Sample code is here:

    function updateChild(child) {
            var props = child.properties;
            var governanceProperty = props.find(property => property.alias === $scope.model.alias);
    
            props.filter(e=>e !== governanceProperty);
    
            if (typeof governanceProperty.value === "string") {
    //I need to check this because for some reason an unpopulated propertyEditor has the value of an empty string...
                governanceProperty.value = {};
                governanceProperty.value.date = new Date().toLocaleString();
            }
            governanceProperty.value.category = $scope.model.value.category;
            governanceProperty.value.reviewPeriod = $scope.model.value.reviewPeriod;
    
            props.push(governanceProperty);
            child.properties = props;
    
            console.log("saving child");
    
            contentResource.save(child, false, []).then(
                function (savedContent) {
                   //THIS RETURNS THE EXPECTED VALUE
                    console.log("attempted:");
                    console.log(child.properties.find(property => property.alias === $scope.model.alias).value);
                   //THIS SHOWS THE VALUE IS UNCHANGED
                    console.log("saved:");
                    console.log(savedContent.properties.find(property => property.alias === $scope.model.alias).value);
                });
        }
    

    Any assistance is greatly appreciated

  • ross Horsey 2 posts 72 karma points
    Dec 18, 2017 @ 17:50
    ross Horsey
    0

    Ok, solved this myself so I figured I should share what I found for anyone else who trips up on this.

    The object returned has a properties array on it, but this is NOT where you should be updating content.

    Instead, you need to find the right tab in the tabs array, then update your property on that.

Please Sign in or register to post replies

Write your reply to:

Draft