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.
describeSObjects()
Field Name | Details |
---|---|
ActorTokenPayload |
|
AssetId |
|
AssetName |
|
AssetSerialNumber |
|
ConnectedAppId |
|
DeviceId |
|
DeviceKey |
|
Expiration |
|
Name |
|
ReplayId |
|
UserId |
|
The following example shows how to trigger an action after an asset token event.
trigger AssetTokenEventTrigger on AssetTokenEvent (after insert) { System.assertEquals(1,Trigger.new.size(),'One record expected'); AssetTokenEvent event = Trigger.new[0]; AssetTokenRecord__c record = new AssetTokenRecord__c(); record.ConnectedAppId__c = event.ConnectedAppId; record.UserId__c = event.UserId; record.AssetId__c = event.AssetId; record.AssetTokenName__c = event.AssetTokenName; record.DeviceId__c = event.DeviceId; record.DeviceKey__c = event.DeviceKey; record.Expiration__c = event.Expiration; record.AssetSerialNumber__c = event.AssetSerialNumber; record.AssetName__c = event.AssetName; record.ActorTokenPayload__c = event.ActorTokenPayload; insert(record); }