I'm trying to use the "Notifications.UserSaved" observer to set an item-field with a value, stored in a cookie, when the user registers through the extranet.
The user is added to a group, which states that the itemtype should be set; when registering and looking at the user in the backend, the itemtype is set correctly for that given user.
But when fetching the user from the "Notifications.UserSaved" observer, the ItemType field is "blank", although the observer states that it fires when the user HAS been saved.
I've tried to get the user by ID aswell, but also here, the ItemType string is empty.
How do i get the ItemType and ItemId from the newly created user, in the "Notifications.UserSaved" observer?
var Logger = Dynamicweb.Logging.LogManager.Current.GetLogger("UserSavedObserver"); Logger.Log("Starting a user saved observer"); if (args == null || !(args is UserNotificationArgs)) return; Logger.Log(" - Args are filled"); UserNotificationArgs item = (UserNotificationArgs)args; // Fetching user. var ActualUser = Dynamicweb.Security.UserManagement.User.GetUserByID(item.Subject.ID); // ALSO TRIED JUST WITH "Item.Subject", same thing. if (ActualUser.ItemType != "Bruger") { Logger.Log("Not right itemtype: " + ActualUser.ItemType); return; /// ENDS HERE AND RETURNS "ActualUser.ItemType"="" } Logger.Log(" - Item-type is Bruger");
Best,
Jonas