Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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.

share|improve this question

1 Answer 1

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">
  <Properties>...</Properties>
  <FilterDescriptors>
    <FilterDescriptor Type="UserContext" Name="Filter by current user">
      <Properties>...</Properties>
    </FilterDescriptor>
  </FilterDescriptors>
  <Parameters>
    <TypeDescriptor TypeName="System.String" IdentifierName="UserName" AssociatedFilter="FilterByCurrentUser" Name="UserName">
      ...
    </TypeDescriptor>
  </Parameters>
  ...
</Method>

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

share|improve this answer
    
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
    
Great, thanks. +1 –  SPDoctor Dec 22 '12 at 10:04

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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