Home > Uncategorized > Unblocking Created By or Modified By at list item level

Unblocking Created By or Modified By at list item level

Using browser interface and out-of-the-box, you cannot unblock “Created By” or “Modified By” because, according to SDK, they are kind of predefined fields based on the current logged-in user. However, using object model there is a way to change these two fields or “Assigned To” field programmatically. Below, you can see a code snippet that assigns a cross-site group to “Assigned To”, a domain group to “Created By” and finally an individual user to “Modified By” field. I have used SPUser.AllUsers[string name] to get the context of my user or group. This method requires that the user passed as the parameter (individual user or group) to be either members of the site or who have browsed to the site as authenticated members of a domain group in the site. If not, this method cannot find the user and you should get an SPUser object representing a the user which has never connected himself to a site. I will cover this one in another post , but for now let’s assume that our user (or group) exists in the site’s membership somehow.

Think twice before you implement such a functionality at list item because if there is any functionalities based on these fields and current logged-in user , they will be messed up since you have overwritten current logged-in user with your choice of security context. In such a scenario, I personally prefer to create a custom field instead of playing around with these fields.

Categories: Uncategorized Tags:
  1. No comments yet.
You must be logged in to post a comment.