trailhead

Enable Salesforce IoT and Create a Context and Dummy Record

Learning Objectives

After completing this unit, you’ll be able to:
  • Enable Salesforce IoT.
  • Explain what a context is.
  • Create a context for a simple use case.

Enable Salesforce IoT

Before you start creating contexts and orchestrations, you first enable Salesforce IoT. Here’s how you do it.

  1. From Setup, enter IoT in the Quick Find box, then select Get Started.
  2. In the Enable Salesforce IoT box, click Enable.
    After you enable, your screen looks like this.

    Salesforce IoT Get Started page with Salesforce IoT enabled

What Is a Context?

A context specifies the sources of data that an orchestration can access: one or more platform events and, optionally, a Salesforce object. Each platform event and optional Salesforce object must have a key field whose values are used by each orchestration instance to access the relevant event messages and object record.

For example, in our Flying Fridge use case, the serial_no key field on our platform event enables an incoming event message to trigger an orchestration instance to run for a specific refrigerator. That orchestration instance matches that key value against the Fridge_Serial_Number key field on the Asset object to read the corresponding asset record for that same refrigerator. Notice that the key field names don’t need to match; only the key values and data types must match.

Create a Context

Let’s create the context for our Flying Fridge use case.
  1. From Setup, enter IoT in the Quick Find box, then select Contexts.
  2. Click New Context.
  3. For Context Name, enter Flying Fridge Context.
  4. For Description, enter All the refrigerator events and object data for fridge orchestrations. This description is displayed in the context detail page.
  5. Click Create.

This is what your context looks like.

Flying Fridge Context showing context detail

Now we add our event data and reference data to the context.
  1. In the context, click Add Event Data.
  2. From the available platform events, select Flying Fridge Event. Click Next.
  3. In Choose the Key, select serial_no__c. Click Apply.
  4. Now click Add Reference Data.
  5. Under available objects, select Asset. Click Next.
  6. In Choose the Key, select FridgeSerialNumber__c. Click Apply.
  7. Click Save, then Activate.
  8. Click Done to exit.

Your context now looks like this.

Flying Fridge Context showing context detail and platform events

Your context is ready to use in an orchestration. We have one last step before we start building our orchestration.

Create Some Data for the Flying Fridge Use Case

Before we go any further with building out our use case, we make sure we have the data we require to test out our use case once all the pieces are put together. In your Trailhead Playground or Developer Edition org, you first create a new field and a new asset record.

Create the new field.
  1. In Setup, click Object Manager.
  2. In Object Manager, select Asset.
  3. In Asset, select Fields & Relationships.
  4. On the Fields & Relationships page, click New.
  5. Select Number, and click Next.
  6. For Field Label, enter Max High Temp.
  7. For Length, enter 18.
  8. For Field Name, enter Max_High_Temp.
  9. Click Next.
  10. Keep the defaults for field-level security, and click Next.
  11. For Add to page layouts, click Save.

Under Fields & Relationships, you now see the Max High Temp field.

Max High Temp field under Asset Fields and Relationships

Now, we create a new asset record.
  1. Click app launcherto open the App Launcher, and under All Items, click Assets.
  2. Click New.
  3. In New Asset, enter an Asset Name, for example, Flying Fridge Mini.
  4. Click Account, and select New Account.
  5. For the Account Name, enter Awesome Airline, and click Save.
  6. Click Contact, and select New Contact.
  7. For Last Name, enter Earhart.
  8. For Account Name, select Awesome Airline.
  9. Click Save.
  10. For Fridge Serial Number, enter 1001.
  11. For Max High Temp, enter 50.
  12. Click Save.

Now, you have an asset record that looks like this.

Asset record for Flying Fridge Mini

Now we have all the pieces in place to move forward with building and testing our orchestration. When we do this, we see how easy it is to create and iterate IoT solutions in Salesforce IoT.

Stay the course and keep exploring.

retargeting