Copied to clipboard

Flag this post as spam?

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


  • Ben 6 posts 96 karma points
    Jan 21, 2020 @ 20:41
    Ben
    0

    Content Service CreateContent method ignoring UserId set.

    Hi,

    I'm using the IContentService within a custom dashboard element. This dashboard imports data and generates nodes with the ContentService.

    Currentl, I have the following two users:

    • Myself (UserId: -1)
    • ImportBot (UserId: 1)

    I'm logged in with my personal account but when the content is created I'm assigning the ImportBot's UserId to the method as shown here:

    _contentService.CreateContent(c.NodeName, parent.GetUdi(), "newsItem", 1);

    However, it always creates the nodes under my account. Is there anyway to force these nodes to be generated by the ImportBot?

  • Dan Diplo 1554 posts 6205 karma points MVP 6x c-trib
    Jan 22, 2020 @ 13:20
    Dan Diplo
    0

    If you are correct this sounds like a bug and should be reported at:

    https://github.com/umbraco/Umbraco-CMS/issues

  • Steve Megson 151 posts 1024 karma points MVP c-trib
    Jan 22, 2020 @ 14:34
    Steve Megson
    100

    I think the user ID you pass to CreateContent ends up being overwritten by the user ID passed to Save or SaveAndPublish (which will both default to -1).

    The IContent you get back from CreateContent should have its CreatorId and WriterId properties set to 1, but Save will then update both properties.

  • Ben 6 posts 96 karma points
    Jan 30, 2020 @ 19:44
    Ben
    0

    Thank you Steve

  • Nitin Anand 46 posts 178 karma points
    Dec 08, 2020 @ 09:27
    Nitin Anand
    0

    any solution ? While copies or copying content , creatorID is changed to 0

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies