Is it possible to send the current user's username as a parameter for my External Content Type query? I am on SharePoint 2010 Standard.


It is possible to create a filter based on the current user. If you're defining a ReadItem method, then you can even do this with the wizard in SharePoint Designer. It's a little more tricky if you want to do the same thing with a ReadList method.

This blog post goes into great detail about the process of adding a UserContext filter to a ReadList method. Here are the steps from a high level:

  1. Create a ReadItem method for the ECT from SharePoint Designer
  2. Export the BDC model and open it in an XML Editor
  3. Locate the filter and parameter in the XML which was added for the ReadItem method
  4. Apply these same values to the xml for the ReadList method
  5. Create an external list based on this ECT to verify that it's working

Here is some sample xml that gives a general idea of what this will look like in the XML:

<Method Name="Read List" DefaultDisplayName="Some list">
    <FilterDescriptor Type="UserContext" Name="Filter by current user">
    <TypeDescriptor TypeName="System.String" IdentifierName="UserName" AssociatedFilter="FilterByCurrentUser" Name="UserName">

Disclosure: I came across this solution while looking at this discussion thread.

  • That's fine. If you could add a bit more information to your answer and include the link just for reference it would be even better. Thanks. [mod] – SPDoctor Dec 16 '12 at 11:17
  • I've updated the answer as requested – atcrawford Dec 21 '12 at 20:53

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.