Copied to clipboard

Flag this post as spam?

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


  • Jason Price 3 posts 73 karma points
    Apr 23, 2022 @ 17:00
    Jason Price
    0

    Mutli Url Picker not setting content in NotificationHandler

    I'm using Umbraco version 9.4.3 and I've created a ContentSavingNotification handler that will call an external API and download some product information, then I set the values of the properties in the content. This is working fine for the Text properties I set but it doesn't work for the Multi Url Picker (MUP).

    As part of the information from the API there is a list of image URLs hosted on an external CDN, I don't want to upload these to the Media Libary and just want to store them as links, so I'm using a MUP property to store the links (its usually about 4 or 5 URLs).

    According to the docs I should be able to build a list of Links, serialise the list to json and set the MUP value to the json string, but when I do this the MUP value is always empty - it never seems to get set.

    This is how I'm setting it in my handler:

                  //build up a list of url links to the images
                    var imageLinks = new List<Link>();
    
                    for (int a = 0; a < item.Images.Count(); a++)
                    {
                        var image = item.Images.ElementAt(a);
                        imageLinks.Add(new Link
                        {
                            Target = "_blank",
                            Name = $"Item-Image-{a}",
                            Url = image.URL,
                            Type = LinkType.External,
                        });
                    }
    
                    //serialise the links to json
                    var links = JsonConvert.SerializeObject(imageLinks);
    
                    //and save it in the content
                    content.SetValue("amazonProductImages", links);
    

    I've confirmed the json string is correct and there are no exceptions being thrown (some of the text properties are set after this code and they're working fine).

    Anyone got any ideas on why it's not working?

  • Jason Price 3 posts 73 karma points
    Aug 09, 2022 @ 20:34
    Jason Price
    0

    I Updated to Umbraco 9.5.2 and it started working...

Please Sign in or register to post replies

Write your reply to:

Draft