2

I installed the salesforce S4S connector in my sitecore and I created one custom object "EmployeeInformation". Now I need to get the records from my custom object and tried to insert the records into my custom object in salesforce.

But I am not able the find the API and its method to do the mentioned activity. Could you help me how to do those activities and share the sample if you have.

Thanks in advance.

Thanks, Karthik

1

Disclose: I work for the company that makes the S4S product.


If you need support with S4S it would be best to contact someone from FuseIT support directly. We are happy to provide customer support via email. The S4S download site also includes code samples and help documentation. In particular, have a look at the Accessing Custom Objects and Custom Fields section in S4S Simple Code Examples.pdf.

That said, there are a number of ways S4S supports custom Salesforce objects in Sitecore.

Generic Entities

If you want a quick way to work with any entity exposed via the Salesforce Partner API you can use the generic entity services.

// This is OK for a quick test, but in practice you should store the credentials 
// in a connection string which is in turn encrypted.
SalesforceSession salesforceSession =   
    new SalesforceSession(new LoginDetails("user@example.com", "password", "securityToken"));
// You can also use the SalesforceSessionSingleton to avoid 
// re-establishing the session constantly

// Note the __c suffix that indicates this is a custom Salesforce object
string customObjectType = "EmployeeInformation__c";
GenericSalesforceService employeeInformationService = 
    new GenericSalesforceService(salesforceSession, customObjectType);

// The service gives you basic CRUD (Create Retrieve Update Delete) methods.
// E.g. Retrieve a single known record by the Salesforce Id
var employeeInfo = employeeInformationService.GetByEntityId("a018000000TGNKL");

// Get a custom field from the custom object
string richText = employeeInfo.InternalFields["TestRichField__c"];

// If you want to query the custom object you can use a DataSource.
var employeeInfoDataSource = 
    new GenericSalesforceEntityDataSource(customObjectType, salesforceSession);
employeeInfoDataSource.AddDataSourceFilter("Name", 
    Operator.OperatorFor(ComparisonOperator.StartsWith), "Test");
List<GenericSalesforceEntity> matchingEmployeeInfos = employeeInfoDataSource.GetQueryResultsAsEntities();

T4 (text template transformation toolkit) generated entities

S4S can generate strongly typed .NET objects for working with custom Salesforce objects. This allows you to work with the entity fields via properties on the generated object. One easy way to do this is to use the Code Generation (T4) tab in the FuseIT SFDC Explorer tool.

This is a good approach if the Salesforce Orgs you are connecting to have a relatively static schema.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.