Source Code from my TechEd OSP309 Session


Below you’ll find the source code for various demos I used during my OSP309 session at TechEd NA 2011.

These source code projects are provided as-is and are for temporary reference only without any support. They will be removed shortly and the final versions will be posted on MSDN Code Gallery. The link to the Code Gallery Projects will be available in this blog post as soon as they’re published.

OSP309 Source Code.zip


Comments (23)

  1. Downloaded your source and ran into a bug..

    the constants in the CRMOnlineCOnnector (show below) are different than the property values gen'd in the xml file for the BDC application

    public class CRMOnlineConnector : ISystemUtility, IAdministrableSystem

       {

    const string crmProxyServiceUrlPropertyName = "CRMProxyServiceReferenceUrl";

           const string crmServerPropertyName = "CRMServer";

    //the need to be changed to this – or update the xml values gend for the bdc file to import

           const string crmProxyServiceUrlPropertyName = "CRMProxyServiceUrl";

           const string crmServerPropertyName = "CRMServerUrl";

  2. Mike says:

    The /createdevicecredentials switch doesn't exist on the crmbcsutil.exe command.  How do you generate the required device credentials?  I was following the directions in the provide word document in the zip file.  Thanks!

  3. girishr says:

    Mike,

    I'll investigate it when I get a chance. The code is essentially using the DeviceIdManager class to create the device credentials. You can modify the code to do it pretty easily. Please see here for reference: msdn.microsoft.com/…/gg328147.aspx

    You can also use this tool (created by one of our MVPs) to create the device credentials: archive.msdn.microsoft.com/…/ProjectReleases.aspx.

    Thanks,

    -Girish.

  4. Mike says:

    Hi Girish, I was able to run the deviceregistration tool from SDK.  However, I'm still having issues getting this to work.  I'm able to generate the out.bdcm file just fine.  When loading this model in I get an error from SharePoint.  

    Application definition import failed. The following error occurred: Cannot find file with Type described by a TypeName on the LobSystem (External System). Parameter name: systemUtilityTypeName Error was encountered at or just before Line: '40' and Position: '20'.

    Any ideas on what I need to do get this to work?  Thanks

  5. Mike says:

    I was able to solve the import failed issue.  For some reason all the .DLLs did not get put into the GAC during the .wsp upload.  I copied both CRMEntityService.SharePoint and CRMEntityService.SharePoint.Connector dlls into the GAC and then did a iisreset on all the sharepoint servers and it worked.

    Now the only issue is that I'm getting all the records back that I think I should be.  So I'm looking into what might be causing records to be filtered.

    Otherwise this thing is pretty cool.  Sure hope it gets more support moving forward.

  6. girishr says:

    Glad that you're able to get it working Mike.

    Regarding the list of records, we're doing a simple pull of data for the current user. You can certainly modify the query to bring the data you need.

    Thanks,

    -Girish.

  7. Mike says:

    Looks like there is a limit filter setup by default that only retreives 30 rows which is causing the result.  Anyway should be able to remove this from the bdcm file and be good to go.

  8. Dick M. says:

    Girish,

    First I would like to thak you for a very nice presentation and the code.

    I have gotten to the point where the web part in SharePoint asks me to authenticate against CRM. Once the authentication goes trhough, I get the following error:

    Unable to display this Web Part. To troubleshoot the problem, open this Web page in a Microsoft SharePoint Foundation-compatible HTML editor such as Microsoft SharePoint Designer. If the problem persists, contact your Web server administrator.

    Correlation ID:182cac5d-a2f8-4a47-bb56-e2f62bc0b8e0

    I found some posts about the item limit and changed it up, but I'm still getting the error. Any ideas?

    Thanks,

    Dick M.

  9. Dick M. says:

    Addendum to my previous question-

    It seems that the external content type can't recognize identity columns or null values. I saw a few online posts about this.

    I've created a profile page for "Account" and the page returns the following error:

    Item not found in CRM Online (Steward).

    Correlation ID:f3268b95-e903-43cd-b461-7ed9439893b3

    The query could not be executed because one or more identifier values could not be converted to the proper type. The exception was: 'System.IO.InvalidDataException: Found invalid data while decoding. at Microsoft.BusinessData.Runtime.Identity.DecodeElement(String s, Int32& index) at Microsoft.BusinessData.Runtime.Identity.Deserialize(String serializedIdentity) at Microsoft.SharePoint.Portal.WebControls.BdcUtility.FindEntity(IEntity entity, String finderName, Object[] userValues, ILobSystemInstance lobSystemInstance)'.

    Do you have any insight on this?

    Thanks,

    Dick

  10. Rotor says:

    The generated BCDM appears to have some superfluous tags, I had to remove all instances of <TypeDescriptors/> for the BCDM file to pass validation.

  11. @Dick

    I'm getting exactly the same error message. Can you share tips on how you solved it?

    Thanks

  12. I checked out the ULS logs and there seems to be some exception in the *CRMEntityService.SharePoint.Connector.CRMOnlineConnector.ExecuteStatic* method. I just uploaded the logs here on <a href="pastebin.com/…/a>. Can you go through it once and tell me where exactly things are going wrong?

  13. Rotor says:

    Hi all

    If you get an error regarding "Entity xy does not contain attribute StateCode", you have to change EntityService.cs, line 147 to:

                   if(entityMetadata.Attributes.Keys.Contains("statecode"))

                   {

                       qe.Criteria.AddCondition(new ConditionExpression("statecode", ConditionOperator.Equal, new object[] { 0 }));

                   }

    or remove the condition altogether and do the filtering (if desired at all) on the SharePoint side of things.

    Regards

  14. Praba says:

    How to implement the security trim in the search results for the external conten source. Using the above connector i have created a ECT and searching fine. But i need to implent the securit part – how to implement the checkaccess or securitydescriptor methond in the bdcm file for the above connector. is there any articles to follow up by steps.  

  15. Jacob says:

    Is there a way to filter the results in the finder with a wildcard filter?

    Today we have 500 accounts and only the first 30 is retrieved. I tried changing the limit filter, but SharePoint still limits it to 200.

  16. Hi Girish I'm able to generate the out.bdcm file but when loading this model in I get an error from SharePoint.  

    Application definition import failed. The following error occurred: Cannot find file with Type described by a TypeName on the LobSystem (External System). Parameter name: systemUtilityTypeName Error was encountered at or just before Line: '40' and Position: '20'.

    I already have CRMEntityService.SharePoint and CRMEntityService.SharePoint.Connector dlls into the GAC and already did a iisreset on the Sharepoint Server,

    Do you have any ideas, or is there a final release of this code and the one in this post is outdated?

    Thank you very much

  17. girishr says:

    @Kevin,

    Can you try changing the list of entities/attributes for which you are generating the model. I'm not sure what the culprit might be.

  18. Hi Girish,

    I am unable to authenticate the CRM Online. I am getting the following error

    "Error: An unsecured or incorrectly secured fault was received from the other party.". Do you have any idea?

  19. Tony says:

    Hi Girish,

    why my service proxy can't talk with crm service, I alwasys get the error when the call from connector response = (RetrieveEntityResponse)serviceProxy.Execute(request); even I tried  serviceProxy.Execute(new WhoAmIRequest()); also get internal error, and no error message cameback because that I don't know how to turn the crm servcie errow message on.

    Thanks,

  20. Hi Giresh,

    I'm getting this error when trying to import the bdcm file into Office365 SharePoint 2013:

    Application definition import failed. The following error occurred: Cannot find file with Type described by a TypeName on the LobSystem (External System). Parameter name: systemUtilityTypeName Error was encountered at or just before Line: '40' and Position: '20'.

    I've seen your fix to deploy the “CRMEntityService.SharePoint.Connector.dll” to the GAC – but pretty sure I can't do that on o365??

    Any ideas?

    Cheers – MC

  21. Francois Heurion says:

    Hi Girish,

    I cannot run your code because the solution is not under source control: I would have to connect to your server. Can you tell me how to do it? Hereafter the error message I got.

    TF400324: Team Foundation services are not available from server wlgtfs2.intergen.org.nz.

    Technical information (for administrator):

     The remote name could not be resolved: 'wlgtfs2.intergen.org.nz'

  22. girishr says:

    Francois,

    You should be able to disconnect it from TFS using visual studio. Unfortunately I don't have an environment at the moment to do that and repost the code.

  23. Mário says:

    Hi Girish,

    This project has support for CRM field type "Option Set"?

    Can you give an exemple of the xml file including one entity with one field of this type?

    Thanks.