Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...


If your coding preference is strongly typed C# objects over using string names to access custom fields in Salesforce then this can be achieved in two ways:

...

using the T4 template generation

...

tab in FuseIT SFDC Explorer. There is a tab that is specifically for this purpose. Just drag the entities in the left panel to the selection surface and generate strongly typed C# custom objects that can be used in your Sitecore code. Note that you may need to make some namespace changes to the generated code

...

.

...

Please note that although strongly typed objects are architecturally superior, using them adds effort when a developer needs to add a new Salesforce custom field to a custom web form. For this reason, most customers use string names to work with custom objects and fields.  

Code Generation using Visual Studio

S4S can generate strongly typed classes for a designated Salesforce organization using T4 (the Text Template Transformation Toolkit) in Visual Studio. Within the FuseIT.Sitecore.SalesforceCodeGeneration project open the Entities.tt template.

Ensure the FuseIT.Sitecore.SalesforceConnector.dll file can be located by the generation process:

Code Block
languagec#
<#@ assembly name="D:\xxxxx\S4S\FuseIT.Sitecore.SalesforceConnector\bin\Debug\FuseIT.Sitecore.SalesforceConnector.dll" #>

Also ensure valid Salesforce Partner API credentials are available under the line:

Code Block
languagec#
//TODO: Set Salesforce Partner API credentials here
salesforceSession = new SalesforceSession(new LoginDetails("yourUserName", "yourPassword"));

Once saved the T4 code generation will produce the file Entities.cs.

For each Salesforce object (x) accessible via the Partner API the following classes will be generated:

  • x : EntityBase
    Represents a single object instance
  • xService : SalesforceServiceBase<x>
    Service class for performing CRUD (Create, Retrieve, Update, Delete) operations using the entity objects
  • xDataSource : SalesforceDataSource
    Provides querying against the specific object type with support for filters.

These generated classes can then be used for strongly typed data access into the specific Salesforce instance.

...

S4S can batch API calls when attempting to create, update, or delete more than 200 records.

Code Generation using FuseIT SFDC Explorer

...

Enter a Namespace and select the remaining options. Clicking Generate will create a folder at the nominated location containing the strongly typed C# classes that you can add to your .NET project.

For each Salesforce object (x) accessible via the Partner API the following classes will be generated:

  • x : EntityBase
    Represents a single object instance
  • xService : SalesforceServiceBase<x>
    Service class for performing CRUD (Create, Retrieve, Update, Delete) operations using the entity objects
  • xDataSource : SalesforceDataSource
    Provides querying against the specific object type with support for filters.

These generated classes can then be used for strongly typed data access into the specific Salesforce instance.