[Subscribe(Dynamicweb.Modules.UserManagement.Notifications.UserOnBeforeSave)] public class NotificationSubscriber1 : NotificationSubscriber { public override void OnNotify(string notification, NotificationArgs args) { Dynamicweb.Modules.UserManagement.UserNotificationArgs a = (Dynamicweb.Modules.UserManagement.UserNotificationArgs)args; a.Subject.Department = "hej"; // throw new ArgumentException(groupIds); a.Subject.Save(); } }
Developer forum
E-mail notifications
Notificiation subscriber UserOnBeforeSave
Keld Gøtterup
Posted on 01/11/2011 16:43:55
im trying to change a value of a member property but when trying to save() i seem to end up in loop. (save -> onsave -> save ->onsave) is there a way to save the value without looping?
Replies
Pavel Volgarev
Posted on 01/11/2011 16:51:02
This post has been marked as an answer
Hi Keld,
I'm pretty sure that you don't need to call "Save" in your notification subscriber because the user will be saved automatically after this notification is dispatched to all subscribers.
-- Pavel
I'm pretty sure that you don't need to call "Save" in your notification subscriber because the user will be saved automatically after this notification is dispatched to all subscribers.
-- Pavel
Votes for this answer: 0
Jeppe Eriksson Agger
Posted on 01/11/2011 17:02:24
Indeed. Pavel is correct, but if you still explicitly want to call the Save() method then you could maintain a variable in the Items cache that indicates if you've already done the save or not. If you have, simply return from the subscriber.
Not doing the save is still the best solution, though.
- Jeppe
Keld Gøtterup
Posted on 02/11/2011 09:02:25
i thought i tried, but obviously i didn't because it works like a charm.
Thanks :)
You must be logged in to post in the forum