Thanks Ishai, that works. I have to confess I didn't spot the SystemUpdate() method otherwise I'd have given it a go before. ________________________________
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Ishai Sagi Sent: Tuesday, 8 July 2008 7:14 AM To: [email protected] Subject: [OzMOSS] RE: ItemAdded vs ItemAdding for assigning permissions ItemAdded is where you should make changes to security. As for preventing the email - I am not sure, but try to use listItem.SystemUpdate() instead of listItem.Update() Ishai Sagi Solutions Architect Information Services Mobile: 04 2379 1728 Email: [EMAIL PROTECTED] Web: www.uniqueworld.net <http://www.uniqueworld.net> Blog: www.sharepoint-tips.com <http://www.sharepoint-tips.com/> <http://www.uniqueworld.net/> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Crabbe, David Sent: Monday, 7 July 2008 18:21 PM To: [email protected] Subject: [OzMOSS] ItemAdded vs ItemAdding for assigning permissions I've got an event handler for a Task list that assigns item-level permissions such that only the 'Assigned To' user or group has Contribute access to edit the item. Unfortunately, by updating the item in ItemAdded, I seem to trigger another built-in event because I receive an email along the lines of "Tasks - <task name> has been changed". I am using DisableEventFiring() and EnableEventFiring() on either side of my update but I'm not able to stop the "has changed" email: // create a new role assignment based upon the user or group SPRoleAssignment roleAssignment = new SPRoleAssignment(principle); // create a new role definition for Contribute access and bind it to the role assignment SPRoleDefinition roleDefinition = web.RoleDefinitions.GetByType(SPRoleType.Contributor); roleAssignment.RoleDefinitionBindings.Add(roleDefinition); // temporarily disable any event handling on the item to prevent looping this.DisableEventFiring(); // break the normal permissions inheritance and replace with the item-level permission defined above listItem.BreakRoleInheritance(false); listItem.RoleAssignments.Add(roleAssignment); listItem.Update(); // re-enable the event handling on the item this.EnableEventFiring(); I thought about using the ItemAdding event handler, however in reading Ishai's blog ( http://www.sharepoint-tips.com/2006/09/synchronous-add-list-event-itemad ding.html) <http://www.sharepoint-tips.com/2006/09/synchronous-add-list-event-itema dding.html)%20I've> I've realised that only the AfterProperties of the list item are exposed. I need a reference to the list item itself to change the permissions associated with it, ergo ItemAdded. Am I missing something or is this a quirk of Task lists? David. David Crabbe Consultant Web Solutions Team Fujitsu Australia Ltd T: +61 8 9268 1505 E: [EMAIL PROTECTED] This is an email from Fujitsu Australia Limited, ABN 19 001 011 427. It is confidential to the ordinary user of the email address to which it was addressed and may contain copyright and/or legally privileged information. No one else may read, print, store, copy or forward all or any of it or its attachments. If you receive this email in error, please return to sender. Thank you. If you do not wish to receive commercial email messages from Fujitsu Australia Limited, please email [EMAIL PROTECTED] ------------------------------------------------------------------- OzMOSS.com - to unsubscribe from this list, send a message back to the list with 'unsubscribe' as the subject. Powered by mailenable.com No virus found in this incoming message. Checked by AVG - http://www.avg.com Version: 8.0.138 / Virus Database: 270.4.6/1539 - Release Date: 7/07/2008 18:35 PM ------------------------------------------------------------------- OzMOSS.com - to unsubscribe from this list, send a message back to the list with 'unsubscribe' as the subject. Powered by mailenable.com ------------------------------------------------------------------- OzMOSS.com - to unsubscribe from this list, send a message back to the list with 'unsubscribe' as the subject. Powered by mailenable.com
<<image001.gif>>
