Copied to clipboard

Flag this post as spam?

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


  • ianhoughton 281 posts 605 karma points c-trib
    Jun 13, 2022 @ 11:37
    ianhoughton
    0

    Strange error when trying to create content programatically

    I have Umb 8 & Vendr working nicely. This morning, I have needed to create a node in the root of the website programmatically so create a method in my ApplicationComponent like this:

    private void CreateSettingsSection()
        {
            using (var ctx = _umbracoContextFactory.EnsureUmbracoContext())
            {
                var settingsNode = ctx.UmbracoContext.Content.GetAtRoot().FirstOrDefault(x => x.IsDocumentType(Settings.ModelTypeAlias));
                if (settingsNode == null)
                {
                    var node = _contentService.Create("Settings", -1, Settings.ModelTypeAlias);
                    var result = _contentService.SaveAndPublish(node);
                }
            }
        }
    

    but the code fails to run due to a Vendr licensing issue (we dont have a license bought as yet, but I'm running it on localhost).

    enter image description here

  • Matt Brailsford 4123 posts 22194 karma points MVP 9x c-trib
    Jun 13, 2022 @ 12:36
    Matt Brailsford
    0

    Hey Ian,

    It looks like an event handler we have that runs on publish to enforce the max SKU's permitted by a license is having a problem as it seems to expect it running in a request context (which it is obviously plausable that this is not the case).

    I'll add it to our issue tracker to review, but it will likely not be till after CG now so early next week before I get chance to review it.

    Are you able to work around this for the time being?

  • ianhoughton 281 posts 605 karma points c-trib
    Jun 13, 2022 @ 12:44
    ianhoughton
    0

    Hi Matt,

    Yeah, no problem. This code is a nice to have, so I'll mark it TODO !!

  • Matt Brailsford 4123 posts 22194 karma points MVP 9x c-trib
    Jun 13, 2022 @ 12:46
    Matt Brailsford
    0

    Actually, I'm a little surprised that CanFingerprint is erroring really as we already null check the Request so not sure why it's throwing.

    If you want to test a fix in the mean time, I've added a try catch to this to capture any faults. You can access this on our unstable nuget feed for the time being (it'll be release next week after v10 is launched as the unstable feed currently supports v10 RC)

    https://nuget.outfield.digital/unstable/vendr/v3/index.json

    The build you'll want to install is v2.3.0-beta042

    I'll re-review when I'm back to see if there is a reason it could still be erroring and if there is a better option than the try catch

    Update Issue tracker link is https://github.com/vendrhub/vendr/issues/374

Please Sign in or register to post replies

Write your reply to:

Draft