Developer forum

Forum » Development » How to retrieve ExtranetExtended module group collection on UserOnBeforeSave

How to retrieve ExtranetExtended module group collection on UserOnBeforeSave

Jesper Laustsen
Reply

 [Subscribe(Dynamicweb.Modules.UserManagement.Notifications.UserOnBeforeSave)]

public class NotificationCreateUser : NotificationSubscriber

I'm doing an NAV integrated usercreation routine, and need to act on the event UserOnBeforeSave, to check if userinformation is available in NAV, before doing creation in both DW and NAV. However, I need to tell NAV, which groups, the user is going to be a member of, when the creation succeeds, so I need to retrieve the group collection set diretly on the module.
(Important!: NOT the group collection on the user, as it (of course) is still empty before creation, but the group collection on the module itself.

Thanks in advance...

Jesper/NORRIQ


Replies

 
Morten Bengtson
Reply
This post has been marked as an answer
Hi Jesper,

The group collection on the user is NOT empty on UserOnBeforeSave notification when user is created - unless no group is selected in the module settings.

[Subscribe(Dynamicweb.Modules.UserManagement.Notifications.UserOnBeforeSave)]
    public class UserSaved : NotificationSubscriber
    {

        public override void OnNotify(string notification, NotificationArgs args)
        {
            var savedArgs = args as Dynamicweb.Modules.UserManagement.UserNotificationArgs;
            if (savedArgs != null)
            {
                var user = savedArgs.Subject;

                var groups = user.Groups;
                
            }
        }
    }


/Morten
Votes for this answer: 0
 
Jesper Laustsen
Reply

OMG... You wouldnt believe me if I told what I just discovered. MAJOR Brain fart.


Ok... a hint, as I looped through the Groups collection, I forgot to actually insert the group id's to my string builder :-(

But thanks for the quick reply :-)

/Jesper

 

You must be logged in to post in the forum