Salesforce Connected Services in Visual Studio
One of the hardest parts of building modern applications and integrations is dealing with the multitude of services that companies depend on everyday. More and more applications are moving to the SaaS model. The modern enterprise developer is creating “mash-ups” between home grown internal applications and cloud based business applications. For instance, you may be tracking bugs using Visual Studio Online and managing Customer Support using Salesforce Service Cloud. Each of
those have robust APIs for accessing the data. Things start to get messy when setting up and configuring both your Visual Studio project and the services themselves.
Most services provide OAuth for identity and authentication. And each service has their own idiosyncrasies for creating an OAuth configuration. In Salesforce you need to create a Connected App to obtain a client id and secret, specify a callback url, and define the scope for your app. This is common across almost all services that use OAuth. Where it gets tricky is in trying to find out where to configure these in each service’s web interface.
Connected Services helps to solve these problems by launching a wizard that is created by the Service Provider to guide the developer through the process all the while staying within Visual Studio. Here is a Channel 9 video where Steve Lasker and I discuss connected services with Seth Juarez
Salesforce has teamed up with Microsoft to create a Salesforce Connected Service extension for Visual Studio. All that is needed is an Administrator login to Salesforce and the Salesforce Connected Service will quickly walk the developer through a wizard that will create a Connected App, setup an OAuth handler class for the project, install Nuget packages required for using the Force.com Toolkit for .NET and create data models for any objects that you select. All of this without every going to Setup inside of Salesforce.
The screencast below shows how this works.
One of the main philosophies driving the developer experience is that this is your code and you maintain control. This philosophy demands that only the required changes to your project are made and no extra sample code is added. Instead, when the Connected Service wizard is finished, we provide a summary of all the changes made to your project. And rather than install sample code that needs to be removed, the Connected Service provides walkthroughs that demonstrate how to use that particular service.
The Salesforce Connected Service does not generate code but rather scaffolds code into your project. Generated code differs from scaffolded code in that you can reliably edit the scaffolded code with the knowledge that if you run the wizard again your changes will be preserved. This is not the case with generated code.
Also, due to the rich metadata APIs available for Salesforce, the models that are generated are attributed to reflect the metadata of your objects and fields. For instance, the field label is used to define the DisplayName attribute. Other attributes that are generated are “updateable” and “createable” to enforce your business logic.
You can add additional fields by updating the Salesforce Connected Service. In this case, no new OAuth configuration is created, instead just the additional objects are scaffolded. You can also control how objects are scaffolded. Scaffolding uses T4 Templates that you can customize. This gives you even more control over the modeling process. Along with the summary of project changes and walkthroughs, instructions on how to customize and use the customized templates are also provided.
As a .NET developer you don’t need to learn the entire breadth of the Force.com platform. With the Salesforce Connected Service all you need to know is how to run the wizard and your username and password!