Newer Version Available
AssetTokenEvent
Represents an event associated with an asset token,
such as token issuance and registration of a connected device as an Asset. This
object is available in API
version 39.0 and later.
An asset token event records successful completion of an OAuth 2.0 asset token flow for a connected device. An event is published whenever an access token and actor token (optional) are successfully exchanged for an asset token. This object is designed to support custom business processes, such as automatic logging of a case when an event occurs. Create Apex triggers that subscribe to an event and execute after asset token issuance. This object is read only and can’t be retrieved using a SOQL query. Asset token events are not displayed in the Setup user interface for Platform Events.
Supported Calls
describeSObjects()
Fields
| Field Name | Details |
|---|---|
| ActorTokenPayload |
|
| AssetId |
|
| AssetName |
|
| AssetSerialNumber |
|
| ConnectedAppId |
|
| DeviceId |
|
| DeviceKey |
|
| Expiration |
|
| Name |
|
| ReplayId |
|
| UserId |
|
Usage
The following example shows how to trigger an action after an asset token event.
1trigger AssetTokenEventTrigger on AssetTokenEvent (after insert) {
2 System.assertEquals(1,Trigger.new.size(),'One record expected');
3 AssetTokenEvent event = Trigger.new[0];
4 AssetTokenRecord__c record = new AssetTokenRecord__c();
5 record.ConnectedAppId__c = event.ConnectedAppId;
6 record.UserId__c = event.UserId;
7 record.AssetId__c = event.AssetId;
8 record.AssetTokenName__c = event.AssetTokenName;
9 record.DeviceId__c = event.DeviceId;
10 record.DeviceKey__c = event.DeviceKey;
11 record.Expiration__c = event.Expiration;
12 record.AssetSerialNumber__c = event.AssetSerialNumber;
13 record.AssetName__c = event.AssetName;
14 record.ActorTokenPayload__c = event.ActorTokenPayload;
15 insert(record);
16}