Copied to clipboard

Flag this post as spam?

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


  • Tom 713 posts 954 karma points
    May 16, 2019 @ 23:53
    Tom
    0

    Setting Grid Value from existing PropertyType - Programatically Move Prop and Value

    Hi all I have a situation where I want to move a grid property type and it's value from one doc type to another programatically.

    So I'm doing something like so:

    foreach (var group in contentPageDocType.PropertyGroups.ToArray())
                {
                    foreach (var prop in group.PropertyTypes.Where(pt => myPage.HasProperty(pt.Alias) && myPage.GetValue(pt.Alias) != null))
                    {
                        //Store the composed property type values so we can manually add them back in after removing the composition
                        composedPropertyValues.Add(new PropertyValueGroupStore { PropertyType = prop as PropertyType, PropertyValue = loyaltySummaryPage.GetValue(prop.Alias), GroupName = group.Name });
                    }
                }
    

    And then iterating over the built up properties, groupings etc and transferring them over to my other node of a given doc type and calling

    Content.SetValue(propertyAlias, value);
    

    This is creating the grid datatype but almost appears to be escaping the JSON and that json then appears in each grid row with an error in the admin section. Grid content error

    I originally tried property.DeepClone() unsucessfully.

    Any advice would be most appreciated!!

Please Sign in or register to post replies

Write your reply to:

Draft