SPList docLibrary = web.Lists["Enterprise Documents"]; SPQuery query = new SPQuery(); query.Query = ""; SPListItemCollection documents = docLibrary.GetItems(query); foreach (SPListItem doc in documents) { if (doc.Fields["Owner"] != null) { SPFieldUser ownerField = doc.Fields.GetField("Owner") as SPFieldUser; SPFieldUserValue ownerValue = ownerField.GetFieldValue(doc[ownerField.Id].ToString()) as SPFieldUserValue; SPUser owner = ownerValue.User; string ownersEmail = owner.Email; ... <where><eq><fieldref name="ContentType"><value type="Text">Enterpise Document</value></fieldref></eq></where>
Because we have multiple content types in this library, I added code to make certain that the content type of the document under review is based on our custom "Enterprise Document" content type since only that content type contains the "Owner" field mentioned above. Anyway, I thought this might be useful to share since it took me several iterations before I figured it out.
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.