none
How can I filter a Sharepoint 2007 libarry list based on current user login?

    Question

  • Hi all.

    I would like to know how I can filter a SharePoint library list based on current user login.

    Suppose I have created the followings:

    1) A SharePoint form library containing bunch of uploaded InfoPath form data.

    2) The InfoPath form template contains a promoted text field called "TargetUser" to store user domain login (ex: DOMAIN\JOE) and every InfoPath form file in the library has a valid domain name stored in the "TargetUser" field.

    I have created a custom view for the form library and would like to filter this view so only items whose "TargetUser" field matches current user's login ID are displayed.

    I went to Edit View page to customize the view and tried to use the [Me] function but I got a "Filter value is not a valid text string" message instead when clicking OK. Apparently [Me] returns a Person/Group data type and the filter cannot compare its value to that of "TargetUser".

    I tried using text functions (ex: TEXT([Me],"") hoping to extract default string value from [Me]. The filter accepts the parameter without any error but the resulting fitlered list does not display any items at all.

    I have googled this subject for hours but I have not found any solution.

    It would be greatly appreciated if anyone can help me to create a functional filtered list.

    FYI, my SharePoint 2007 installation is just WSS 3.0 + Form Server. I do not have MOSS 2007 (so no MOSS 2007 web parts or web services).

    Thank you.

    Jason

    Monday, October 04, 2010 10:58 PM

Answers

  • Here's what I usually do in order to accomplish this.  Ultimately you'll need to have 2 different fields.  There's the one you already have, with DOMAIN\username stored in it.  Then you'll need an additional field as a "person" column type.  Call it "TargetPerson" or something.

    Create a sharepoint designer workflow that runs each time an item is created or changed.  One action:

    Set FIELD to VALUE.

    The first FIELD is "TargetPerson", the VALUE is your "TargetUser" field. 

    Once this is done, then the person value is stored in the person field.  This is the field that you can filter by "TargetPerson" is equal to [Me]


    Laura Rogers, MCSE, MCTS
    SharePoint911: SharePoint Consulting
    Blog: http://www.sharepoint911.com/blogs/laura
    Twitter: WonderLaura
    • Marked as answer by jlinx2000 Tuesday, October 05, 2010 8:02 PM
    Tuesday, October 05, 2010 4:23 AM

All replies

  • Hi Jason,

    The [Me] function can be used only with default columns like Modified By, Created By etc. You cannot use the [Me] function in a calculated column.

    I have found some good links to solve this. Please go through them

    http://www.infopathdev.com/blogs/greg/archive/2005/09/08/Use-the-SharePoint-_27005B00_Me_5D002700_-Filter-with-a-Promoted-Property.aspx

    http://blueinfopath.blogspot.com/2008/10/create-personal-sharepoint-views.html

    Hope it is helpful


    Cheers, Hemendra-MCTS "Yesterday is just a memory,Tomorrow we may never see"
    Tuesday, October 05, 2010 4:08 AM
  • Here's what I usually do in order to accomplish this.  Ultimately you'll need to have 2 different fields.  There's the one you already have, with DOMAIN\username stored in it.  Then you'll need an additional field as a "person" column type.  Call it "TargetPerson" or something.

    Create a sharepoint designer workflow that runs each time an item is created or changed.  One action:

    Set FIELD to VALUE.

    The first FIELD is "TargetPerson", the VALUE is your "TargetUser" field. 

    Once this is done, then the person value is stored in the person field.  This is the field that you can filter by "TargetPerson" is equal to [Me]


    Laura Rogers, MCSE, MCTS
    SharePoint911: SharePoint Consulting
    Blog: http://www.sharepoint911.com/blogs/laura
    Twitter: WonderLaura
    • Marked as answer by jlinx2000 Tuesday, October 05, 2010 8:02 PM
    Tuesday, October 05, 2010 4:23 AM
  • Hi,

    Modify the view and add Current User Filter Web Part. Now configure that web part and rest of your requirement will be taken care by that web part itself.

     

    Let me know if you have any query...


    thanksArup MCTS - SharePoint

    Play Sudoku Online
    Tuesday, October 05, 2010 1:08 PM
  • Hi Laura,

    Your approach of creating an extra Person/Group field and using a workflow to update the field appears to be the best solution. I will probably adopt this approach from now on when creating new Sharepoint sites or libraries.

    As for the current library which I would like to make changes to, the only issue I have now is to trigger the new workflow so all items in the library will be updated. I will google again and see if that can be done easily. Of course, if you already know how to do that it would be appreciated if you can share the info with us.

    Thank you.
    Jason

    Tuesday, October 05, 2010 8:08 PM
  • Arup,

    As mentioned earlier, I only have WSS 3.0 and Form Server installed.  No MOSS 2007.

    So "Current User Filter Web Part" is not available for me to use.

    Jason

    Tuesday, October 05, 2010 8:09 PM
  • Hemendra,

    Thanks for those links.
    The second one appears to be same approarch that Laura suggested.

    Thanks.
    Jason

    Tuesday, October 05, 2010 8:15 PM
  • Just an update on triggering workflow.

    Although I did not find any easy way to trigger workflows for multiple items on Google but I remember that whenever I modified the form library's xml files directly in notepad, the updated files would trigger workflows.

    So I did a litte test and open the form library in Windows Explorer, copied a few files to another location and then copy those file back to the library in Windows Explorer. And workflows were triggerd for items which I copied back to the library.

    I think I just need to temporary diable other workflows and leave the one which will update the Person/Group field and then do the magic using Windows Explorer. :)
    Tuesday, October 05, 2010 8:50 PM
  • Hi there,

    I am following instructions given by you but I am getting error in workflow i.e, error updating a list item and error occured in workflow. I have given users add and edit item permission to the from library.

    Please advice!

    Thanks

     

     

    Monday, November 08, 2010 7:42 PM
  • Hi,

    You can use the Information Policy management to start the workflow.  Use something like created +0days.

    It will update every record on the list via the workflow that way.  Schedule to run say at 12 midnight. Or set it up and run it manually from CA, via the timer jobs schedule.  It is a timer job that runs. Always works for me.




    • Edited by CrjangelFG Thursday, February 13, 2014 8:39 PM
    Thursday, February 13, 2014 8:39 PM