I'm writing a method in my trigger handler to see if a field has changed and then will send the record ID and user lookup id to a handler class to create a new record.
I've copied other methods in the class and adjusted where I need to however, I get the error
map must have exactly 2 type arguments (Line: 2, Column: 5)
Here is what I have, what did I do wrong?
public static void createSalesParticipant(Map<Id, Opportunity> newMap, Map<Id, Opportunity> oldMap)
{
Map<Opportunity> salesParticipants = new Map<Opportunity>();
for(Opportunity oppy : newMap.values())
{
if(oppy.Sales_Participant_1__c != null && oldMap.get(oppy.Id).Sales_Participant_1__c != oppy.Sales_Participant_1__c)
{
salesParticipants.add(oppy.Id, oppy.Sales_Participant_1__c);
}
}
Best Answer
Here's where you went wrong:
Maps need to have two data types, one for the Key, and one for the Value.
It seems to me you're confusing List/Set and Map, since you're also trying to use "add"; the Map type uses "put" instead.
Finally, it seems that you're really just trying to map one Id to another, so you probably meant: