This tutorial demonstrates how to integrate SpreadsheetWEB with SalesForce API to push data into SalesForce database.

Create your Salesforce Account

To build a Salesforce application, the first thing you’re going to need is a Salesforce account. If you don’t have one already, use this link to sign up:

https://developer.salesforce.com/signup

Once you’ve created your account and verified your email address, log into your account at the following address:

https://developer.salesforce.com/login

 

Grab Salesforce WSDL Reference

Salesforce offers various web service access options when interacting this its API; in this example, we’re going to be using their SOAP-based service to create in the system. Leads are standard data objects in SalesForce. The following page can help you determine which service you may want to utilize for your projects:

https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_quickstart_intro.htm

To start the implementation, we must pull down the correct package from Salesforce’s WSDL offerings based on the endpoint that we are interested in interacting with. This will give us the types that are necessary for working with their SOAP-based API.

For our scenario, we’re going to be using Salesforce’s Enterprise WSDL. You can search for this from the Quick Find box on the upper right corner of the Salesforce main page (note: if you’re having trouble locating the target contents, use the keyword API and then go to Custom Code / API).

Alternatively, you can go to this page to download the component:

https://eu10.lightning.force.com/lightning/setup/WebServices/home

 

Creating the Custom Code Assembly

Create the Project and Generate Service Reference

Next, we can start creating our application in Visual Studio. Open Visual Studio and create a new C# Class Library.

We will begin our integration by generating service references against the provided Salesforce WSDL that we downloaded in the prior step. This will allow us to interact with their web service using strongly typed classes to ensure compliance with their service contracts.

Once Visual Studio creates and finishes loading the new project, right-click on your project (Solution Explorer > YourProjectName) and select Add > Service Reference.

In the next window, you will need to enter the WSDL path.

Enter the WSDL path into the Address section and press the Go button. You should see the SforceService service detected under the Services section. Enter your preferred namespace in the Namespace input and press OK to continue.

 

The Custom Code Class Implementation

Next, we’re going to add references to requisite SpreadsheetWEB API assemblies. Add the following *.dll files from the package into your project as references:

Pagos.Designer.Interfaces.External.dll

Pagos.SpreadsheetWeb.SpreadsheetWebAPI.dll

Pagos.SpreadsheetWeb.Web.Api.Objects.dll

The available custom action hooks within the Designer are exposed in the external interfaces assembly. By creating a class that implements one or more of these interfaces, you can trigger execution of custom code at the following target events:

IBeforeCalculation

After the calculation request has been generated based on the application’s requirements, but before the calculation request has been sent to the calculation engine. This provides for a moment to modify the calculation request before it is sent, as well as validate and cancel subsequent actions.

IAfterCalculation

After the response from the calculation has been received but before all subsequent processes, such as save, print, and email generation. This provides for a moment to modify the results from the calculation response before they are processed, as well as validate and cancel subsequent actions. This will be executed even if there is no save action associated with the button.

IBeforeSave

After the response from the calculation has been received but before all subsequent processes, such as save, print, and email generation. This provides for a moment to modify the results from the calculation response before they are processed, as well as validate and cancel subsequent actions. This will not be executed if there is no save action associated with the button.

IAfterSave

After the response from the calculation has been received and the save action has been performed (i.e. all requested save data has been stored in the database), but before all subsequent processes, such as print and email generation. This provides for a moment to modify the results from the calculation response before they are used in subsequent processing, as well as validate and cancel subsequent actions. This will not be executed if there is no save action associated with the button.

In this example, we’re going to be using the IAfterCalculation interface on our object in order to push the lead record to Salesforce when the user hits the calculate button.

Some sample code that performs this action can be seen below (please disregard the “HTML” title below, this is code is in C#):

Compile the assembly once the code is satisfactory for your scenario.

 

Creating your SpreadsheetWeb Application

Basic Application Creation Walkthrough

Log into your SpreadsheetWEB Control Panel and press Create a New Application.

Select Designer as the type and click Next.

Select your Excel file under the Excel Spreadsheet box and press Next after giving your application a name.

Assign your application to a group and click Next.

Finally, click Return to Application List to go back to the main page.

Under the Applications page, click the orange Edit Designer Application next to the application name.

This will take you to the Designer home menu.

 

Uploading your Custom Action for Subsequent Usage

Proceed to Custom Actions.

In the next screen, click Add Custom Action.

After giving your custom action a name, select or drag-and-drop the *.dll compiled assembly file into the Custom Action File box. Once the file upload has completed, press Create Custom Action.

You will then be able to see the custom action class and the available events that can be triggered. This page is for your information and this data will not be visible to the end user. Go to the main designer menu by clicking the Designer logo on the top left corner.

 

Creating your User Interface

Now, we can create a user interface and push the data into Salesforce. Go to the User Interface menu to start building the UI.

In the designer, all controls must be placed inside sections. Begin by dragging and dropping a section control into your page. In this example, we also use two textbox inputs inside of this section – drag two instances of the textbox control into the section.

Click on each of the textbox inputs to configure them. Under the Named Range dropdown, select the iName and iEmail named ranges (i.e. bind each of those named ranges against an input).

Finally, we’re going to add an action button to the page. The action button can be configured by clicking on it once it has been placed on the page. Select your custom action from the Events option.

Once you’re done, remember to press the Submit button to save your changes. You can now click on Preview in the dial menu or the right-hand properties menu to see a preview of the application.

Entering data into the form and pressing the Submit button will submit the information to Salesforce. You will be able to see this data under the Salesforce Leads screen.

 

Defining Named Ranges in Excel

The aforementioned iName and iEmail are named ranges that are associated with the sample workbook that was utilized to generate this application. These names correspond to a single cell in the workbook.

You can use either of the following methods to create named ranges in Excel:

Name Manager

Select the Formulas ribbon and click on the Name Manager.

Click the New button.

Define the name and use the Refers to input to point to a target cell (or series of cells).

 

Upper Left Cell Reference Name Field

Select the cell (or series of cells) that you would like to name. In the upper-left corner of the Excel window (below the ribbon), enter the desired name into the name field and hit Enter.