Start tracking your progress
Trailhead Home
Trailhead Home

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 a Salesforce object. Each platform event and 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. Click Get Started.
  4. For the Salesforce object, select Asset, and click Next.
  5. From the available platform events, select Flying Fridge Event, and click Next.
  6. Select key fields. Choose the key field for the Asset object first. Select serial_no__c.
  7. Then, select FridgeSerialNumber__c as the key field for the platform event.
  8. Click Next.
  9. For Context Name, enter Flying Fridge Context.
  10. For API Name, enter Flying Fridge events and object data.
  11. Click Finish.
  12. Click Save, and then click Activate.

This is what your context looks like.

Flying Fridge Context showing context detail

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.