Copied to clipboard

Flag this post as spam?

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


  • Jun 12 posts 92 karma points
    Mar 03, 2021 @ 04:04
    Jun
    0

    How do I add a record to umbracoUserStartNode table?

    Hi there,

    I am trying to find a way to add a record to umbracoUserStartNode table. I read through the document around the user and database but could not find anything helpful.

    May I ask if there is an existing service that Umbraco provides that I can call directly?

    Kind regards, June

  • Marc Goodson 2157 posts 14435 karma points MVP 9x c-trib
    Mar 03, 2021 @ 20:18
    Marc Goodson
    100

    Hi June

    The UserService, allows you to 'Save' either a User or UserGroup object.

    And both these objects have a property 'StartContentId' that represents the 'StartNode'

    https://github.com/umbraco/Umbraco-CMS/blob/34e80d86e8c0b754f6b7a02e307f53cb32806bbe/src/Umbraco.Core/Models/Membership/User.cs

    https://github.com/umbraco/Umbraco-CMS/blob/34e80d86e8c0b754f6b7a02e307f53cb32806bbe/src/Umbraco.Core/Models/Membership/UserGroup.cs

    So I imagine if you use the UserService to retrieve an existing User or UserGroup object

    https://github.com/umbraco/Umbraco-CMS/blob/0bd4dced0b3e9205660114406b7e814f817179c7/src/Umbraco.Core/Services/Implement/UserService.cs

    Set the value of the StartContentId, and then use the UserService to Save the updated object, then you should find this alters the value in the database table...

    ... if I've understood what you are trying to achieve!

    regrds

    Marc

  • Jun 12 posts 92 karma points
    Mar 03, 2021 @ 22:11
    Jun
    0

    Thank you very much, Marc, that's exactly what I am looking for!! Your solution also makes me realized I should start looking at the object model for this kind of requirements.

    Much appreciated your help!

  • 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