Developer forum

Forum » Development » Add item to itemlist on user

Add item to itemlist on user

René Poulsen
Reply

Hi,

I'm working on a solution where I've added an itemlist to users, so we can create multiple contactpersons on the user. Is it possible to add items to this itemlist when creating a new user via the API?


Replies

 
Lars Larsen
Reply

Hi René

You could use this notification subscriber which subscribes to an event fired when a user is saved. Add your code here to populate the itemlist on the saved user

    [Dynamicweb.Extensibility.Subscribe(Dynamicweb.Modules.UserManagement.Notifications.UserSaved)]
    public class UserSavedObserver1 : Dynamicweb.Extensibility.NotificationSubscriber
    {
        public override void OnNotify(string notification, Dynamicweb.Extensibility.NotificationArgs args)
        {
            if (args == null || !(args is Dynamicweb.Modules.UserManagement.UserNotificationArgs))
                return;

            Dynamicweb.Modules.UserManagement.UserNotificationArgs item = (Dynamicweb.Modules.UserManagement.UserNotificationArgs)args;

            //TODO: Add code here
        }
    }

 

You must be logged in to post in the forum