Platform Event
A platform event is a special kind of Salesforce entity, similar in many ways to a custom object. An event message is an instance of a platform event, similar to how a record is an instance of a custom object. Unlike with custom objects, you can’t view event records in the Salesforce user interface, or update or delete them.
You can set read and create permissions for platform events. You grant permissions to users in profiles or in permission sets.
You create platform events from the Setup menu. Let’s create a platform event definition that holds the event data from the Flying Fridge refrigerators.
Define a platform event named Fridge Event.
- From Setup, enter Platform Events in the Quick Find box, then select Platform Events.
- On the Platform Events page, click New Platform Event.
- For Label, enter Flying Fridge Event.
- For Plural Label, enter Flying Fridge Events.
- For Description, enter Flying Fridge events received from commercial refrigerators.
- Click Save.
- In the Custom Fields & Relationships related list, click New.
- Select Text, and click Next.
- For Field Label/Name, enter serial_no.
Later, we use this serial_no field as the key for matching event messages with orchestration instances.
- For Length, enter 255.
- Click Required.
The platform event key field must be a required field.
- Keep the defaults for the other fields and leave the Description field empty. Click Save.
- Follow steps 7, 8, and 9 to add the next two fields:
Field Label/Name Field Type
door_open Checkbox
temperature Number (Length=18)
After following the steps above, you have a platform event object that looks like this.
Create a Key Field on the Asset Object
Add a custom field to the Asset object that we use as the key.
- In Setup, click Object Manager.
- In Object Manager, select Asset.
- In Asset, select Fields & Relationships.
- On the Fields & Relationships page, click New.
- Select Text, and click Next.
- For Field Label, enter Fridge Serial Number.
- For Length, enter 255.
- For Field Name, enter Fridge_Serial_Number.
- Select Unique. Do not allow duplicate values.
- Click Next.
- Keep the defaults for field-level security, and click Next.
- For Add to page layouts, click Save.
This blog is very useful to learn about platform event.