I created a PV Lookup (showing Possible Values) for a custom table for a Microsoft Dynamics SL 2015, CU 1, SDK application. Immediately after pressing F3 I got a TargetInvocationException in Visual Studio. The Visual Studio Output window listed an unhandled exception in the Microsoft.Dynamics.SL.Controls assembly at SetSqlDataSource. Digging into the Call Stack showed the exception came from the CTLBPVSql method in the swimapi.dll. A SQL Trace showed a statement that ran correctly using my credentials, but Dynamics SL runs it as the login created for reports, E8F575915A2E4897A517779C0DD7CE. I hadn’t granted Select permission on the custom table for that database user, and doing so immediately resolved the issue.
My conclusion: when creating a custom table for Dynamics SL 2015 for an SDK application, always grant Select permission to this user. Hopefully all the technical stuff in this post will help you find you way here if you run into the same thing! Who would guess that a TargetInvocationException would be resolved by granting a SQL Select permission?
GRANT SELECT ON [xYourCustomTable] TO [E8F575915A2E4897A517779C0DD7CE]