You need to sign in to do that
Don't have an account?

Publish and Subscribe to a Platform Event in an Apex Trigger
While I am trying to complete Trailhead module for platform events, this is the error message which I am getting.

This is the code which I have written as of now,

Kindly advise if any changes are required.
Regards
Chetan
This is the code which I have written as of now,
Kindly advise if any changes are required.
Regards
Chetan
please add below line after ts.ownerid :
tasks.add(ts);
thanks
varaprasad
Thank for the respose. As instructed, I added above mentioned line and now my code looks like this:
But still getting the same error message as above and not able to complete challenge.
Regards
Chetan
Can you set the whoid in task as contact and see
trigger OrderEventTrigger on Order_Event__e (after insert) {
List<Task> tasks = new List<Task>();
for (Order_Event__e event : Trigger.New) {
if (event.Has_Shipped__c == true) {
Task ts = new Task();
ts.Priority = 'Medium';
ts.Status = 'New';
ts.Subject = 'Follow up on shipped order ' +
event.Order_Number__c;
ts.OwnerId = '';
tasks.add(ts);
}
}
insert tasks;
}
Please note in inverted comma next to OwnerId put any active user's id.
Regards
Chetan
Let us know if this will help you
Regards
Chetan
PLEASE LET ME KNOW!!
Dnt query record. Try to use userinfo.getuserid(); to get user Id. Try to update your code like below
Let us know if this will work
Abraços.
Célio Xavier