how to linq query spfield to spuser

cranfan
  • how to linq query spfield to spuser cranfan

    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

  • 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

Tags
Related questions and answers
  • . Scoped to Site. Registration: contains a ListTemplate and a ListInstance that just modifies a basic Custom List to enable content types and add my custom content type. Scoped to Web. Here's what's happening. When I activate ContentTypes, the content type and field are deployed as expected into my site collection. When I activate Registration, the list is provisioned and the content type is added as expected. When I try to add a new item to the list, the list form only shows the Title field from Item. Now, here's the weird part. If I add a second content type to the list (through the UI

  • UPDATE Worth noting that this is only happening when the site definition is called from SPWebApplication.Sites.Add, if I use the UI then this works fine. My code is impersonating the system account when calling this code. Am I right in thinking that the ApplyWebTemplate() method of SPSite is asynchronous? If this is the case then my issue is probably one of timing. I.e. the required... happening on our live farm. It did not happen on dev or in the test environment so I am hoping it is a configuration change, but all references I can find on Tinterweb (sic) are related to the Field Type

  • So I did create on an SPWeb 20 custom lists and then a tasks list. For each of those 20 lists I've created 20 site lookup columns. I then created 20 Content Types based on Task content type... using ListViewByQuery control. Here is how an SPQuery looks: <Query> <Where> <Eq> <FieldRef Name='Relaterat_x0020_till_x0020_avtal' LookupId='TRUE...; </Eq> </Where> </Query> then it is working. Here is the code: // create listViewByQuery ListViewByQuery listViewByQuery = new ListViewByQuery(); listViewByQuery.List

  • I am wanting to access survey information via the Lists web service and display the questions contained in the survey. The result contains a large number of Field nodes some of which are the questions in the survey. The other fields contain other information such as author, last changed etc. How can I pick out the questions? I had thought that all non-questions would be hidden but this is not the case. Here is my code as it is at the moment. It returns about 16 items. The survey has 6 questions... // read question definitions string[] HandleTypes = new string[] { "Number", "DateTime

  • ;/RenderPattern> In WSS 3.0, this would render the 2nd column in the field as a hyperlink in the LVWP, which is what I want. In SharePoint 2010, I tried adding TRUE to my field type definition...Has anybody upgraded an old custom field type to use the new XSL transform in SharePoint 2010? I have a multi-column field type, and want the Display pattern to render the 2nd "column", which contains a hyperlink. My CAML render pattern looks like: <RenderPattern Name="DisplayPattern"> <Switch> <Expr> <Column /> </Expr> <Case Value

  • I have a document library using a document set content type. I can create a new document set through the UI and it works perfectly. I'm now trying to create a document set in this library programmatically and it's not working properly. Here is the code (based on MSDN documentation): // Set some properties Hashtable properties = new Hashtable(); properties.Add("UploadComplete", false... that both internal fields HTML File Type and ProgId should be SharePoint.DocumentSet but instead they are blank changing a field value on the document set folder doesn't propogate to its contents

  • I'm trying to create a view of stuff from my reusable content list. Basically I am storing global links within the reusable content list. I'm struggling with the content query webpart, because it always shows me the LINK to the item in the reusable content list - what I want it to show is the ReusableHTML Column of the specific item in the list. I tried doing so with <property name...; And basically I want to display these global links via the masterpage of my site - easily editable for the end user in the reusable content list. Anyone up for a .webpart file or could show me

  • I have created a recursive query that contains 2 multi user fields. After much thrashing, where I would add the and had my query return no results, I found that the FieldRef needed to include Nullable="TRUE" and Type="UserMulti". This works, in the query now returns the correct number of records, however the value in my 2 multi user fields is empty. <View> <Webs Scope="Recursive...; <FieldRef Name="ID" /> <!-- Field which do not return values --> <FieldRef Name="Responsible" Nullable="TRUE" Type="UserMulti" /> <FieldRef Name="Accountable

  • sorry if this is a noob question, but I have to start somewhere! I'm working with Sharepoint 2007. I have a custom content type, Room Booking Event. When one is created, I want to start a workflow where the following happens: Using email, I want to send the details of the room booking (fields in the list), to an approver Ideally, I want the approver to be able to approve the booking right there in Outlook (using an InfoPath form?) If thats not possible, I could include a link to the content approval page I'm really not sure where to start here. I have had a look at the OOTB approval

Data information