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-itema
dding.html)
<http://www.sharepoint-tips.com/2006/09/synchronous-add-list-event-itema
dding.html) I'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

Reply via email to