You need to sign in to do that
Don't have an account?
Platform Events Basics 3/3 Subscribe to Platform Events - Challenge solution
Easy challenge, copying the code of CloudNewsTrigger and including small changes, but I have stucked with the UserId.
Using this code for OrderEventTrigger you will pass the course:
Good luck!
Using this code for OrderEventTrigger you will pass the course:
trigger OrderEventTrigger on Order_Event__e (after insert) { // List to hold all tasks to be created. List<Task> tasks = new List<Task>(); // Get queue Id for task owner //Group queue = [SELECT Id FROM Group WHERE Name='Regional Dispatch' LIMIT 1]; String usr = UserInfo.getUserId(); // Iterate through each notification. for (Order_Event__e event : Trigger.New) { if (event.Has_Shipped__c == true) { // Create Task to dispatch new team. Task ts = new Task(); ts.Priority = 'Medium'; ts.Status = 'New'; ts.Subject = 'Follow up on shipped order ' + event.Order_Number__c; ts.OwnerId = usr;//queue.Id; tasks.add(ts); } } // Insert all tasks corresponding to events received. insert tasks; }
Good luck!
it Is Look like thi.
Order_Event__e newsEvent = new Order_Event__e(
Has_Shipped__c = true);
Database.SaveResult sr = EventBus.publish(newsEvent);
After that do the 'Check challenge'.
trigger OrderEventTrigger on Order_Event__e (after insert) {
// List to hold all tasks to be created.
List<Task> tasks = new List<Task>();
// Get queue Id for task owner
//Group queue = [SELECT Id FROM Group WHERE Name='Regional Dispatch' LIMIT 1];
String usr = UserInfo.getUserId();
// Iterate through each notification.
for (Order_Event__e event : Trigger.New) {
if (event.Has_Shipped__c == true) {
// Create Task to dispatch new team.
Task ts = new Task();
ts.Priority = 'Medium';
ts.Status = 'New';
ts.Subject = 'Follow up on shipped order ' + event.Order_Number__c;
ts.OwnerId = usr;//queue.Id;
tasks.add(ts);
}
}
// Insert all tasks corresponding to events received.
insert tasks;
}
Variable does not exist: Status
Variable does not exist: Subject
Variable does not exist: Owner Id
DML requires SObject or SObject list type: List<Task>
these errors are displaying . How to resolve it?