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:
- Create a ReadItem method for the ECT from SharePoint Designer
- Export the BDC model and open it in an XML Editor
- Locate the filter and parameter in the XML which was added for the ReadItem method
- Apply these same values to the xml for the ReadList method
- 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.