function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Michaela PrambsMichaela Prambs 

Creating Apex Triggers

Hello everyone,

this challenge seems to be not so difficult, but here is what I got:

error

I really don't know what I have done wrong :( cause the challenge is really easy to do...

Michaela
Best Answer chosen by Michaela Prambs
Amit Chaudhary 8Amit Chaudhary 8
Please check below post. I hope that will help u
https://developer.salesforce.com/forums/?id=906F0000000BV53IAG

The code in the Trailhead Project called "Creating Apex Triggers" is incorrect in lines 4 and 10. 
Here is the existing code:
03     //collect ID's to reduce data calls
04     List<Id> speakerIds = new List();  
05     Map<Id,DateTime> requested_bookings = new Map<Id,DateTime>();
06     
07     //get all speakers related to the trigger
08     //set booking map with ids to fill later
09     for(Session_Speaker__c newItem : trigger.new) {
10         requested_bookings.put(newItem.Session__c,null); /
11         speakerIds.add(newItem.Speaker__c);

Here is the revised code:
03     //collect ID's to reduce data calls
04     List<Id> speakerIds = new List<Id>();  
05     Map<Id,DateTime> requested_bookings = new Map<Id,DateTime>();
06     
07     //get all speakers related to the trigger
08     //set booking map with ids to fill later
09     for(Session_Speaker__c newItem : trigger.new) {
10         requested_bookings.put(newItem.Session__c,null);
11         speakerIds.add(newItem.Speaker__c);

Notice there is no / at the end of line 10.  Thanks to my super-dev guy Kyle for helping me with this!

https://developer.salesforce.com/trailhead/project/salesforce_developer_workshop/creating_triggers


Please let us know if this will help you

Thanks
Amit Chaudhary
 

All Answers

Amit Chaudhary 8Amit Chaudhary 8
Please check below post. I hope that will help u
https://developer.salesforce.com/forums/?id=906F0000000BV53IAG

The code in the Trailhead Project called "Creating Apex Triggers" is incorrect in lines 4 and 10. 
Here is the existing code:
03     //collect ID's to reduce data calls
04     List<Id> speakerIds = new List();  
05     Map<Id,DateTime> requested_bookings = new Map<Id,DateTime>();
06     
07     //get all speakers related to the trigger
08     //set booking map with ids to fill later
09     for(Session_Speaker__c newItem : trigger.new) {
10         requested_bookings.put(newItem.Session__c,null); /
11         speakerIds.add(newItem.Speaker__c);

Here is the revised code:
03     //collect ID's to reduce data calls
04     List<Id> speakerIds = new List<Id>();  
05     Map<Id,DateTime> requested_bookings = new Map<Id,DateTime>();
06     
07     //get all speakers related to the trigger
08     //set booking map with ids to fill later
09     for(Session_Speaker__c newItem : trigger.new) {
10         requested_bookings.put(newItem.Session__c,null);
11         speakerIds.add(newItem.Speaker__c);

Notice there is no / at the end of line 10.  Thanks to my super-dev guy Kyle for helping me with this!

https://developer.salesforce.com/trailhead/project/salesforce_developer_workshop/creating_triggers


Please let us know if this will help you

Thanks
Amit Chaudhary
 
This was selected as the best answer
Michaela PrambsMichaela Prambs
It helped! Thank you so much :)
Bill Hare 29Bill Hare 29
I'm having the same issue - per the above - I checked the code and it looks like it has been updated so I'm not sure what else to do - any thoughts?