Developer guide
Getting started
Feel free to skip this section If you’re already familiar with developing Salesforce (SF) applications. For those who need a refresher, this section covers the basic concepts of Salesforce development.
There are multiple ways to develop a Salesforce application. The most common method is to use the Developer Console, a web-based integrated development environment (IDE). Alternatively, many developers prefer Visual Studio Code (VSCode), which offers a more user-friendly and versatile experience. Before diving in, review the Get Ready to Develop guide on Trailhead.
When using the VSCode approach, it’s important to understand that your local project directory mirrors the structure of Salesforce components in the connected DevHub or Scratch Org. In essence, Salesforce artifacts—such as Apex classes, triggers, and SOQL queries—are represented as files in the project. While most actions you perform in VSCode are executed directly in the Salesforce Org, some exceptions exist, which is irrelevant for this guide.
This development model differs from traditional software development. Think of it as a convenient way to interact with Salesforce components, manage version control, and bundle subsets of components for packaging and deployment, such as publishing apps on AppExchange.

If this seems abstract now, don’t worry — it will all make sense as you progress through the development process.
At the end of this guide, you will be able to:
Create, edit, and query custom metadata objects.
Create and update Apex classes, including unit tests.
Create and update Lightning Web Components.
Development process
Your primary objective with this integration is to utilize Coherent Spark's Execute API to trigger and invoke your externalized calculations. In simple terms, this involves invoking callouts using Apex.
You can think of the Salesforce development process as being divided into three main phases:
Backend development: create or update Apex classes to manage your integration logic;
Frontend development: create or update Lightning Web Components for user interaction;
Custom metadata: define your Spark configurations as needed.
Phase 1: Backend development
In the backend phase, you’ll use Apex classes to represent the input and output data required by your calculation engine. Since Apex is a structurally-typed language, your classes must match the JSON structure expected by the version of Execute API you choose to work with.
To harness SparkClient.cls, let's now implement a basic use case simulating a callout to Spark service.
The example above of a callout service implementation uses dummy data to refer to Spark settings needed to trigger the calculation engine residing in Coherent Spark. In a real-world scenario, you would want to collect your input data as a custom object from SF, then feed it into Spark to run complex calculations, and finally collect the output data as part of your business data for further processing.
Below is what you'll need to add more unit tests to your test suite for SparkClient.cls:
An HTTP callout mock class to simulate what the backend service would respond with based on a given request.
Then, the actual unit tests for the
SparkClient.clsandSparkService.cls.
Further readings on Apex classes can be found here:
Phase 2: Front-end development
The frontend phase might feel more approachable than the backend development, mainly because it’s more visual and interactive. That is, you'll be creating user-interactive components to enhance the user experience for Salesforce admins.
If you’re already familiar with web development technologies like HTML, CSS, and JavaScript, you’ll find this phase straightforward. If you’re not a web developer, we recommend starting with the LWC Guide to help you understand the basics of Lightning Web Components (LWC) before you can proceed. Roughly speaking, LWC is a Salesforce-proprietary modern framework for building web components. The following resources can help you grasp how LWC works behind the scenes:
Explore design principles and pre-built components with Lightning Design System.
Learn about individual components like buttons, badges, and cards from LWC Component References.
Access examples of commonly used patterns and components from LWC Recipes on GitHub.
Here's an LWC example using the existing backend service SparkService.cls:
Phase 3: Custom Metadata
Custom metadata in Salesforce stores reusable, deployable configurations for application logic, such as business rules or integration settings. It’s ideal for static data, as records can be queried in Apex without consuming SOQL limits.
Custom metadata also supports custom fields, declarative setup, and seamless deployment between orgs, making it a powerful tool for centralizing and managing configurations efficiently. Hence, it makes sense to store Spark settings such as base URL, tenant name, API key, or other static resources there.
In the example below, an anonymous Apex script (a more direct way to execute Apex code directly in the SF org) is used to query the defined custom metadata object Spark_Settings__mdt and print its content.
What's next?
This was a brief explanation of how to bring your Excel-based calculation logic to Salesforce. There's definitely more that can be done with Spark within Salesforce. Please reach out to the Coherent Sales team for more information.
Last updated
