Copied to clipboard

Flag this post as spam?

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


  • Jonathan L Folland 31 posts 173 karma points
    Nov 07, 2023 @ 11:31
    Jonathan L Folland
    0

    Specify key (guid) when creating content and media items

    I would like to know if it is possible to specify an item's key when creating the item programmatically; or less preferred, change its key after creation.

    I would like to do this for data import feeds where I have a source with keys. In this manner, future updates from the source can look for the item using a direct look up on a key versus index search.

    I would like to be able to do this with both content and media items. Is this possible?

  • Huw Reddick 1929 posts 6697 karma points MVP 2x c-trib
    Nov 07, 2023 @ 16:37
    Huw Reddick
    100

    I've not attempted this, but according to intelisense Key has a setter, so you could maybe try

                    var post = _contentService.Create(postName, parent, "forumPost");
                    post.Key = Guid.Parse(YOUR GUID);
                    _contentService.SaveAndPublish(post);
    
  • Jonathan L Folland 31 posts 173 karma points
    Nov 17, 2023 @ 17:04
    Jonathan L Folland
    0

    I can confirm this works. For some reason, it just did not even think I could just set the property and save. Thank you.

Please Sign in or register to post replies

Write your reply to:

Draft