1

Here is my code.

SPUser approver = mySite.EnsureUser(approverId);
var selectedItems = listItems.Cast<SPListItem>().Where(p => p.Fields["WF_Approver"] == approver);

my list items field "WF_Approver" is field type of person or group. my approver is type of SPUser.

So how can i check the equation here between SPField and SPUser ?

btw

p.Fields["WF_Approver"].ToString()==approver.loginname 

didn't work either.

Thanks

1

Try using this to get the SPUser from the field:

SPUser userFromField = 
    new SPFieldUserValue(web, p.Fields["WF_Approver"].ToString());

Where web is the current SPWeb

  • Thanks that casting didn't work but inspired me inanother way,i solved it like this p["WF_Approver"].ToString()==approver.loginname it is very easy but at that time i couldn't think this. – cranfan Jun 16 '10 at 5:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.