Skip to content

Apex API

iDialogue platform events can be raised from Apex. A global util class is provided for use by subscriber orgs.

The rooms.PlatformEvent class uses a fluent interface for setting event context before calling the publish() method.

rooms.PlatformEvent evt = new rooms.PlatformEvent()
.withType( 'DOCUMENT_VIEW' )
.withRoom( roomId )
.withRecord( oppty.Id )
.withRecordType( 'Opportunity' )
.publish();

rooms.PlatformEvent Utility Class

global with sharing class PlatformEvent {
global PlatformEvent(){}
/*
* success = false indicates this is an error message.
* Include error details in the withMessage( str ) method.
*/
global PlatformEvent withSuccess(Boolean success){
return this;
}
global PlatformEvent withType(String eType){
// See [Event Types](../../events/types)
return this;
}
global PlatformEvent withRecord(String id){
return this;
}
global PlatformEvent withRecord(SObject obj){
return this;
}
/*
* The SObject name for RecordID
* Example: Opportunity
*/
global PlatformEvent withRecordType(String t){
return this;
}
global PlatformEvent withSubject(String s){
return this;
}
global PlatformEvent withMessage(String msg){
return this;
}
global PlatformEvent withContact(Contact c){
return this;
}
global PlatformEvent withContact(String id){
return this;
}
global PlatformEvent withUser(User u){
return this;
}
global PlatformEvent withUser(String userId){
return this;
}
global PlatformEvent withRoom(DocumentRoom__c r){
}
global PlatformEvent withRoom(String roomId){
return this;
}
global PlatformEvent withRoomItem(DocumentRoomItem__c item){
return this;
}
global PlatformEvent withRoomItem(String itemId){
return this;
}
global PlatformEvent withRoomMember(DocumentRoomMember__c member){
return this;
}
global PlatformEvent withRoomMember(String memberId){
return this;
}
global PlatformEvent withValue(Double val){
return this;
}
/*
* Defaults to current DateTime.now() if not provided.
*/
global PlatformEvent withTimestamp(DateTime dt){
return this;
}
global PlatformEvent withContentDocument(String cid){
return this;
}
global PlatformEvent withContentDocument(ContentDocument dc){
return this;
}
global PlatformEvent withContentVersion(String cid){
return this;
}
global PlatformEvent withContentVersion(ContentVersion cv){
return this;
}
global PlatformEvent withAttachment(String aid){
return this;
}
global rooms__Event__e toRecord(){
// Validates and creates a rooms__Event__e platform event record.
}
global PlatformEvent publish(){
// Publishes the event
}
global class EventException extends Exception{
}
}