You need to sign in to do that
Don't have an account?
Natalya Murphy
Event trigger doesn't appear to be firing
This is for the "Subscribe to Platform Events" unit in the "Platform Event Basics" module. I have:
- Created the trigger
- Created a test class
- Verified that the trigger is active
- Set up debug logging on my user ID and on Automated Process
- set up tracing on the trigger
- added system.debug messages in the trigger
When I run the apex test, I see no evidence of the trigger getting fired. Debug Logs also don't show any evidence of trigger firing.
The ApexTrigger Event Type log in the Salesforce Event Log File Browser does not show the trigger being fired.
What am I missing? Code for trigger and test is below.
- Created the trigger
- Created a test class
- Verified that the trigger is active
- Set up debug logging on my user ID and on Automated Process
- set up tracing on the trigger
- added system.debug messages in the trigger
When I run the apex test, I see no evidence of the trigger getting fired. Debug Logs also don't show any evidence of trigger firing.
The ApexTrigger Event Type log in the Salesforce Event Log File Browser does not show the trigger being fired.
What am I missing? Code for trigger and test is below.
trigger OrderEventTrigger on Order_Event__e (after insert) { System.debug('OrderEventTrigger firing'); List<Task> allTasks = new List<Task>(); Task newTask = null; System.debug('Order count: ' + Trigger.New.size()); for( Order_Event__e nextOrder : Trigger.New ){ System.debug('Shipped: ' + nextOrder.Has_Shipped__c); if( nextOrder.Has_Shipped__c == true ){ System.debug( 'Creating task'); newTask = (new Task(Subject='Follow up on shipped order' + nextOrder.Order_Number__c, Priority='Medium', Status='New', OwnerId=Userinfo.getUserId())); AllTasks.add(newTask); System.debug(newTask); }//if }//for insert allTasks; }
@isTest public class OrderEventTriggerTest { @isTest static void test1(){ Order_Event__e orderEvent = new Order_Event__e(Has_Shipped__c=true, Order_Number__c='333'); Test.startTest(); System.debug('Sending event:' + orderEvent); Database.SaveResult sr = EventBus.publish( orderEvent ); Test.stopTest(); List<Task> tasks = [SELECT Id from Task]; System.assertEquals(1, tasks.size()); } }
Let us know if this will help you
I wrote the test code based on the sample code in the unit and it runs without issue. But it doesn't look like the trigger is being fired.