Overview of Integrating with Salesforce

For a while now, I’ve been meaning to write about integrating with Salesforce. What motivated me to do it is a colleague asking me today: “Hey Luke. I have a system that has to write data back to Salesforce. What are my options?”

What’s an Integration?

An integration is when two or more systems talk to each other to accomplish something.

Two common integration types are

  • Single Sign-On (SSO)
  • Data Exchange

Single Sign-On (SSO) Overview

With Single Sign-On aka SSO, a user signs into one system, typically using their username and password, and then they’re able to sign-in automatically to other systems that are connected to that system without having to sign-in again.

The system where one signs in is known as the “Identity Provider”, or in some circles the “IdP”.

SSO Common Examples

  • A company’s website uses Salesforce as an Identity Provider. When someone tries to access a secure webpage on the website without being signed-in, they’re redirected to the Salesforce login page or community login page. After successfully signing in, they’re redirected back to the requested, secure webpage and are able to view it.
  • A Salesforce community allows one to login to the community using their favorite social media site such as Facebook, Google, Twitter, LinkedIn, etc. This is commonly known as “Social Sign-On”. It’s still SSO but with a social network as the identity provider.
  • An employee has signed in to their work computer and are automatically signed in to Salesforce. The most common example of this is when a company uses Active Directory and when you sign-in to your computer, you’re also signing in to the employer’s network. Since Salesforce can be configured to use your employer’s Active Directory for SSO, it’s a seamless experience to automatically sign-in to Salesforce.

SSO Technical Options Overview

API / Forms Authentication 

A system has a login page in it that accepts a username and password. When someone clicks “Sign In” or “Login”, the system calls the identity provider’s API passing in the supplied username and password, and if they’re signed in, their user information is returned to the calling system and they’re signed in. This used to be the most common way to do it before Open Id and other more secure protocols were created.

OpenID with OAuth2

In my experience, OpenId with OAuth2 is now the default SSO protocol used because it’s more secure and has become widely adopted. The High-Level handshake goes like this:

  1. User tries to access secure webpage and isn’t logged in so user is redirected to the Identity Provider’s website.
  2. The Identity Provider asks the user if they’d like to authorize that system to connect to this system. If they “allow it”, then they’re redirected to the Login page.
  3. User signs in and is redirected to the originally requested secure webpage on the other system along with a user token aka a special sign-in value.
  4. The original system takes this user token and asks the Identity Provider for the user’s information. The identity provider passes back the user’s information such as their name, contact information and possibly security information so the system knows what they have access to.

The primary advantage that this protocol has over “Forms Authentication” is that the users are only entering their credentials on the Identity Provider and the third-party systems never see a user’s credentials. This makes it more secure.

That’s the very quick gist of OpenId. Take a look at the OpenID with OAuth2 Documentation for more information.

SAML

SAML is another common SSO protocol but seems to be less adopted than OpenId. It’s pretty similar to how OpenId works but uses XML and assertions instead of JSON. See the SAML SSO Implementation Guide for more info.

Data Exchange

Data exchange is when two or more systems share data. There are many reasons why two systems would share data. Some common examples are:

  • The company’s e-commerce site integrates with company’s back office system to grab product information and to handle order processing.
  • A company replicates its data from many systems into a central data warehouse so that Business Intelligence software can do various analytics on it.

Data Exchange Models

There are three common models for exchanging data between systems:

  • Push
  • Pull
  • Middleware

Push Model

In a “Push” model, one system tells another system directly here’s the data to use and do something with it such as insert, update, or delete it.

This is most often used for “Real-Time” integrations where as soon as something happens in System A, System B is notified by System A. This allows the two systems to remain synchronized faster. For example, an order is submitted on the e-commerce site and then the site immediately tells Salesforce there’s a new order for that customer so it gets saved in Salesforce too. Another example is an account record is created in Salesforce so Salesforce does a callout to the data warehouse to replicate the data.

Pull Model

In a “Pull” model, one system asks another system directly for information.

This is often used for synchronizing large amounts of data that doesn’t have to be updated frequently because it doesn’t change often or it’s ok if the data isn’t exactly the same for a little while. One example is the data warehouse asking Salesforce for all the latest CRM data that’s changed in the last day.

Middleware

A third system sits between two systems that have to exchange data but the two systems don’t directly communicate with each other. All data flows through the middleware. This can be beneficial because this specialized software is able to handle large volumes of data using various methods and typically doesn’t require any coding. They also usually have pre-built integrations for commonly integrated systems.

Examples

Data Exchange Methods

Now that we’ve covered the high-level models, let’s talk about how the data is exchanged.

Importing & Exporting with Files

This manual process requires someone to generate a file with the data to exchange in System A and then manually import it into System B. One common format is a comma separated value aka CSV file. One can even manipulate the data using common tools such as Excel before importing the data into the target system.

With Salesforce, one can use reports and even listviews to generate export files that can then be imported into other systems.

Pros
  • Usually easy and fast to implement.
  • Good for data that doesn’t have to update often.
  • Salesforce has decent out-of-the-box features for exporting and importing data.
Cons
  • It’s manual so people are involved so this can be slow and error prone.

Application Programming Interfaces (APIs)

An API allows another system to programmatically talk to it without human intervention.  There are different types of APIs such as REST and SOAP but for this overview, we’ll be skipping over those technical differences.

The primary benefit of having an API is that one or more external systems are able to use it to communicate with the system using a standard set of “services”.

Salesforce Enterprise / Partner APIs

The Enteprise and Partner APIs are standard APIs provided by and maintained by Salesforce so that external systems can Create, Read, Update, and Delete records in Salesforce. They come in SOAP and REST versions and are good for handling up to thousands of records at a time.

Salesforce Bulk API

This Salesforce provided API was designed to handle up to billions of records. It’s asynchronous and typically harder to use than the Enterprise or Partner APIs because multiple services have to be used to accomplish a single operation.

Salesforce Custom APIs

Developers can use Apex to create custom APIs that external systems can use to talk to Salesforce. This is typically done for more complicated scenarios and processing that the Enterprise, Partner, and Bulk APIs can’t handle alone.

API Pros
  • Multiple external systems can use the same API to communicate with the system.
  • No human intervention required.
  • Could potentially be easily consumed with standard middleware tools without coding.
API Cons
  • Creating good APIs are hard and time consuming because
    • they require good documentation so other developers can easily use them.
    • it takes a while to design and implement.
  • Often require developer level technical abilities to use.

Salesforce External Objects

This declarative option allows Salesforce to connect to an external system’s API, as long as that external system uses the OData protocol, to create, read, update, and delete the external system’s data from within Salesforce. The data is read and manipulated in real time from within Salesforce without having it stored in Salesforce.

Pros
  • Declarative and fairly easy to set up.
  • Uses object tabs and listviews to interact with the data.
Cons
  • Expensive. I hear it’s like $3-4 thousand per external object. If I’m way off, please let me know.

Salesforce External Services

This declarative option allows one to provide a “service schema file” to Salesforce using a particular format and Salesforce is then able to call an external system’s API using Flows. At the time of this writing, this feature is still in Beta.

Pros
  • Declarative and looks easy to set up.
Cons
  • ?? – Let me know in the comments since I haven’t used this option.

Resources

There are other ways to integrate such as using Canvas Apps and inbound email services but they don’t seem to be used much in my experience.

What did you think of this overview? Are there other integration options? Let us know in the comments.

Use showToast for taking Action After Lightning Record Edit

Whenever possible, I leverage the out-of-the-box Salesforce functionality to implement the desired functionality. One Lightning development feature I’ve used recently is the e.force:editRecord event. In a Lightning component, you can fire this event with a record id and that record’s default edit page will open in a new modal.

That’s great and saves a lot of custom coding, if that’s acceptable. However, after someone edits the record successfully, you’ll want to probably take some action such as updating the display to show the latest edits.

Problem: The force:recordSaveSuccess and force:recordSave don’t fire after the record is edited successfully, at least in Winter 18.

Solution: Use the showToast event to take action after a record is edited successfully.

In the handleToastMessage function, the code is checking for a specific “object saved message” and if it’s found, some specific actions are taken.

If you have a better way of doing this, please let us know in the comments!

Checking Page Permissions in Apex

Recently, I ran into this use case:

Show a link to a Visualforce page only if the current user has access to it. This is usually done for a pilot or a dark launch scenario so that a subset of users only have access to a feature.

Originally, I thought I was going to have to implement this through a custom permission or some other configuration setting without being able to use out-of-the-box visualforce page access through profiles and permission sets. Needless to say, I’m glad I stumbled across the How do I find out if a user has access to a visualforce page through apex? stackoverflow post. In it, Gennadiy describes how one can use the following SOQL to query the SetupEntityAccess standard object to see if someone has access to a given Visualforce page or not.

If the accessSettings list has any records, then the current user has access to the desired Visualforce page. If there are no records, the current user doesn’t have access to the page.

This works with the page being granted access through either the user’s profile or a permission set, despite the ParentId being looked up against the PermissionSetAssignment object.

Salesforce Winter 18 Release Review

Seems like yesterday that Salesforce released Summer 17 and here we are with Winter 18’s pre-release and release notes. Below is my review of the release notes. For a complete list of everything, check out the Winter 18 Release Notes PDF.

Lightning Experience Gets a New Look and Feel

Based on your feedback, we improved information density, legibility, contrast, and even added a splash of color. That means less time scrolling and scanning and more time focused on what matters most. This change applies to Lightning Experience only.

  • More information density and less white space, so you can see more of what you need without scrolling.
  • Improved legibility (using font size and color) to draw attention to what’s most important.
  • Better contrast between foreground and background, making it easier to scan and scroll while staying focused on what you need. We even added color and a background image inspired by our own Trailhead.

That’s a relief because when I implemented Salescloud for a customer, they commented about their being way too much white space so it’s great to see this change coming.

Navigate More Quickly with Keyboard Shortcuts

New keyboard shortcuts allow your users to be more efficient in both console and standard navigation Lightning apps. This change applies to Lightning Experience only. To view the available keyboard shortcuts, press:

• Windows: Ctrl+/

• macOS: Cmd+/

As someone who doesn’t like to leave the keyboard, thank you, especially with simply pressing “e” for editing and “Ctrl+S” for saving!

Set Up Person Accounts with Ease

Ready to start using person accounts? You picked a great time because we steamlined the enablement process. This change applies to both Lightning Experience and Salesforce Classic.

An automated process checks whether or not your org meets the requirements for using Person Accounts. The requirements are:

• At least one record type for accounts.

• Users that have read permission on accounts have read permission on contacts.

• Organization-wide default sharing is set so that Contact is Controlled by Parent or Account and Contact is Private.

From Setup, enter Account Settings in the Quick Find box, and then select Allow Customer Support to enable Person Accounts. After we confirm that your org is ready for Person Accounts, we’ll send an email with additional information about logging a Support case.

Salesforce, I can’t thank you enough for this! I wish you had done this about 5 years ago! At my last employer, our package used Person Accounts heavily, and waiting for Salesforce to enable Person Accounts through a case would usually take 1-2 days. That was even after we streamlined the case body to have all the info they always required, especially the “YES, I am the admin and understand this can’t be turned off once enabled”.

In fact, Ted Husted and I did a “Person Accounts in Action” white paper describing Person Accounts in-depth and published it but have to find it.

Various List View Enhancements

  • Sticky column widths – You can resize a list view’s column width and it remains that size when you return to it later. You can reset it to its original size too.
  • Edit More Records at Once with Mass Inline Editing – You can now update up to 200 records without leaving a list view! Select multiple records, click edit next to the field you want to update, enter the new value and click apply. It’s essentially the same as it worked in Classic. Glad this is finally added because this will really increase a power user’s productivity.

Merge Person Accounts in Lightning Experience

Sales reps can now view duplicates on person accounts in Lightning Experience just as they can on business accounts, contacts, and leads. Users with permission can merge person accounts, too. This change applies to Lightning Experience only.

1. In Setup, make sure that a duplicate rule for person accounts is active.

2. Configure the Potential Duplicates component in Lightning App Builder. Your sales team sees this alert when they view a person account with a duplicate.

I so wish this was available sooner like so many other things. In the past, I had to resort to customizations and other means for this. I wish this was available in Classic too but this is a start!

Better Email Integrations

The Gmail and Outlook integrations are getting better with every release! Task management and two-way syncing are amazing and setting it up is all declarative.

Wave Analytics Renamed to Einstein Analytics

They renamed it and are now including Einstein Discovery. There’s a ton of functionality here and it’s on my to-do list to dig into.

Embed Flows in Lightning Community Pages

Very interesting! This will allow all kinds of new interactions in Communities. Am excited to see how this pans out.

Create Communities in Enterprise, Performance, and Unlimited Editions — Even Without Communities Licenses!

All Enterprise, Performance, and Unlimited orgs can now create up to 100 communities, even without purchasing a Communities license. To start creating your community, first enable Communities in your org. After you create a community, give access to internal users with Salesforce user licenses. Guest users without a license have limited access to your community. Purchase Community Cloud licenses for more access or page views, based on your business needs.

Interesting. I wonder if internal users can now have departmental communities within Salesforce?

Dynamic Lightning Pages

Now you can control when a component appears on a record page by adding filter conditions and logic to its properties. No need to add anything to your custom components. It’s all handled by the Lightning App Builder. For example, construct a filter that causes a rich text component on an opportunity page to display when the Amount is greater than $1 million.

Component visibility filters are supported for standard components, custom components, and components from AppExchange. If you don’t define a filter, the component displays on the Lightning record page as usual. When you define one or more filters and set the filter logic for a component, the component is hidden until the filter logic criteria are met.

Admins can now declaratively define criteria for when a Lightning component is visible on a page through Lightning App Builder. Very nice!

Take Lightning Page Customization to a Whole New Level with Custom Page Templates

Now you’re no longer limited to the standard templates available for Lightning record, app, and Home pages. Take your business needs in hand, and create a custom page template of your own that has the structure and components that you define. Add as many regions as you need, and even custom styling. This feature is available in Lightning Experience and all versions of the Salesforce1 mobile app. It all works by using Lightning components.

Every Lightning page includes a template component that defines the page’s regions and what components it includes. Now you can create a custom Lightning page template component and make it available as a custom page template in the Lightning App Builder’s new page wizard.

There are new interfaces and tags for the .cmp and .design files that help you define the template’s structure, regions, and included components. Each page type has a different interface that the template component must implement.

• lightning:appHomeTemplate

• lightning:homeTemplate

• lightning:recordHomeTemplate

This definitely helps with UI and UX consistency, especially for those building large, custom applications.

Launch a Flow from an Object-Specific Action (Beta)

Add flows to the action menu on your Lightning pages without hunting down the flow’s URL. When you create a flow action, you can pick from a list of available flows rather than enter the flow URL manually. This feature is available in Lightning Experience and all versions of the Salesforce1 mobile app.

Tip: If your flow needs the ID of the record that it’s operating on, don’t worry! Salesforce sends the record ID to the flow as long as you have a Text input variable called recordId.

Thank you thank you thank you! Now, typical workflows can be even more specific per object! I have a few use cases for a client that I can apply this to. I wish this was available in Classic though as with so many of the other new features.

Configure a Flow to Wait for a Platform Event to Occur

You can now subscribe to platform events in a flow Wait element. With platform events, a flow can wait for something to occur, inside or outside your Salesforce org. Previously, a flow could wait only for a relative or absolute date/time value. This feature is new in both Lightning Experience and Salesforce Classic.

This opens up a lot of interesting possibilities since one can now use Flows in this Pub-Sub architecture. This is now on my backlog to experiment with. What use cases can you think of for using this?

Salesforce DX: The New Frontier for App Development (Generally Available!!!)

With a focus on source-driven development, Salesforce DX makes it easier for developers to build together and continuously deliver using the tools that make you most productive. Salesforce Developer Experience (Salesforce DX) will be generally available in mid-October 2017.

Salesforce DX is built on these core principles:

• Source code drives everything.

• Metadata and code are modular.

• Environments are easily created and disposable.

• Development is organized around team collaboration.

• Development is based on open standards and extensibility.

• Flexible packaging supports an agile distribution model.

• Processes and tools facilitate continuous integration and continuous delivery.

Salesforce DX shifts the source of truth from the org to the version control system. By managing your Salesforce code outside of the runtime environment, you can harness industry-standard tools and drive team collaboration during the development and deployment process.

Whether you’re an individual developer or working as part of a large team, Salesforce DX provides an integrated, end-to-end life cycle designed for high-performance agile development. And best of all, we built it to be open and flexible so that you can build together with the tools and practices you know and love.

Simply awesome. This has to be my favorite Winter 18 release feature, by far. Getting changes from one org to another has always been a challenge but this should makes things easier. Additional investigation is needed to see how this can be done with Admins as well.

Lightning Data Service is GA

Spectacular! This is good for standard CRUD operations but for more advanced interactions, APEX is still needed.

Various New Lightning Base Components

There are around 30 new Lightning Base components available. Here are a few that really look interesting:

  • lightning:datatable – More easily display tabular data.
  • lightning:dualListbox – The Classic multi-picklist UI comes to lightning. I wish this didn’t.
  • lightning:flow – Represents a lightning flow in Lightning. Now you can embed flows into custom components and apps. Very nice!
  • lightning:fileUpload – Enables mutiple file to be uploaded to a record. It also includes drag-and-drop and filtering by file types. I wish this existed a couple months ago when I created something similar.
  • lightning:helptext (Beta) – An icon with a text popover. The popover is displayed when you hover or focus on the icon that’s attached to it.

Bulk API 2.0 Generally Available

Bulk API 2.0 uses the same secure, high-performance REST framework as the Force.com REST API, which provides features like OAuth authentication and CORS support. Bulk API 2.0 also provides a streamlined interface for data operations by breaking data files into batches automatically. Upload your data and specify an operation. Salesforce then determines the most efficient way to batch the data.

This is my second favorite new feature. The new API automatically breaks up data files into batches automatically. Thank you. I spent a decent amount of time in the Salesforce Bulk API Starter project getting that to work. Now updating that project to use the 2.0 API is on my backlog!

What features were noteworthy to you?

 

 

 

 

 

 

 

 

 

SALESFORCE LOGGER PILOT

Salesforce is a great company with excellent products and an even better platform. One area that needs more attention is knowing what’s happening in your Salesforce org without enabling Salesforce debug logs. Has a client or a user contacted you saying X is not working and they don’t know what’s going on so you turn on the debug logs hoping for more information and it’s not helpful?

It happens more often than not and troubleshooting it is hard.

Meet Salesforce Logger

This new Logging framework allows one to add logging to their customizations which can then be saved to one or more logging repositories as the customizations are run. Out of the box, it supports saving logs to the debug log, a log custom object, and/or to Loggly, a separate SAAS logging service. If more is needed, one can implement their own persistence logic to save logs wherever they’re needed.

This allows one to monitor the logs to see what errors are happening and how the customizations are being used or not.

Pilot

I’m currently offering this as a free Beta package to pilot testers so they can test it out and provide feedback. If you’re interested in being a pilot tester, follow the instructions at Salesforce Logger Pilot to install, configure, and use the Salesforce Logger Beta package.

When you’re done, Contact Me about what’s good, what needs improvement, how much you’re willing to pay to use this package in production, and any other feedback you’d like to give.

Wanna Try it Out?

Follow the instructions at Salesforce Logger Pilot to install, configure, and use the Salesforce Logger Beta package.

Loggly Example

Here’s an example of a flow error that logs the error to Loggly using a custom FlowError fault handler using an apex class. Am debating if this should be added to the product or not because I’m not sure if this will be more helpful than the regular Flow error email.

What do you think?

Log Custom Object Example

Here’s the same flow error saved as a Log record in the Log__c custom object.