• CarlaMartinez.ax1388
  • NEWBIE
  • 0 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 3
    Replies

I am pretty new to APEX and with help wrote a trigger to auto-update a lookup field based on selecting a value on a picklist field on the account object. It works fine on the Account object.  Now I am trying to replictae it on a custom object and the code below is giving me errors.

 

Error: Compile Error: unexpected token: 'Map" at line 1 column 14



public static Map<String, List<Primary_Sales_Rep__c>> filterPrimarySalesRepsWithChangedVerticals(List<Primary_Sales_Rep__c> incomingPrimarySalesReps,
Map<Id, PrimarySalesRep__c>oldPrimarySalesRepIdToOldPrimarySalesRep)
{

Map<String, List<PrimarySalesRep__c>> verticalNametoPrimarySalesRepList = new Map<String, List<PrimarySalesRep__c>>();

//For all PrimarySalesRep that were sent to out Trigger
for(PrimarySalesRep__c incomingPrimarySalesRep : incomingPrimarySalesReps)
{
//Change conditions
//1.Vertical is now being set
//2. Vertical is being changed

Boolean isChanged
Boolean isInsert - oldPrimarySalesRepIdToOldPrimarySalesRep == null;
PrimarySalesRep__c oldPrimarySalesRep = isInsert ? null : oldPrimarySalesRepIdToOldPrimarySalesRep.get(incomingPrimarySalesRep.Id);

isChanged = (( isInsert && incomingPrimarySalesRep__c.Vertical_Major__c != null)
||(!isInsert && oldPrimarySalesRep__c.Vertical_Major__c != incomingPrimarySalesRep__c.Vertical_Major__c));

if(isChanged)
{
if(!verticalNameToPrimarySalesRepList.containsKey( incomingPrimarySalesRep__c.Vertical_Major__c))
verticalNameToPrimarySalesrepList.put(incomingPrimarySalesRep__c.Vertical_Major__c, new List<PrimarySalesRep__c>));

verticalNameToPrimarySalesrepList.get( incomingPrimarySalesrep__c.Vertical_Major__c).add(incomingPrimarySalesrep__c);
}

}
return verticalNametoPrimarySalesRepList;
}

 

I am pretty new to APEX and with help wrote a trigger to auto-update a lookup field based on selecting a value on a picklist field on the account object. Now I am trying to replictae it on a custom object and the code below is giving me errors. 

Error: Compile Error: unexpected token: 'Map" at line 1 column 14

 

public static Map<String, List<Primary_Sales_Rep__c>> filterPrimarySalesRepsWithChangedVerticals(List<Primary_Sales_Rep__c> incomingPrimarySalesReps,
Map<Id, PrimarySalesRep__c>oldPrimarySalesRepIdToOldPrimarySalesRep)
{

Map<String, List<PrimarySalesRep__c>> verticalNametoPrimarySalesRepList = new Map<String, List<PrimarySalesRep__c>>();

//For all PrimarySalesRep that were sent to out Trigger
for(PrimarySalesRep__c incomingPrimarySalesRep : incomingPrimarySalesReps)
{
//Change conditions
//1.Vertical is now being set
//2. Vertical is being changed

Boolean isChanged
Boolean isInsert - oldPrimarySalesRepIdToOldPrimarySalesRep == null;
PrimarySalesRep__c oldPrimarySalesRep = isInsert ? null : oldPrimarySalesRepIdToOldPrimarySalesRep.get(incomingPrimarySalesRep.Id);

isChanged = (( isInsert && incomingPrimarySalesRep__c.Vertical_Major__c != null)
||(!isInsert && oldPrimarySalesRep__c.Vertical_Major__c != incomingPrimarySalesRep__c.Vertical_Major__c));

if(isChanged)
{
if(!verticalNameToPrimarySalesRepList.containsKey( incomingPrimarySalesRep__c.Vertical_Major__c))
verticalNameToPrimarySalesrepList.put(incomingPrimarySalesRep__c.Vertical_Major__c, new List<PrimarySalesRep__c>));

verticalNameToPrimarySalesrepList.get( incomingPrimarySalesrep__c.Vertical_Major__c).add(incomingPrimarySalesrep__c);
}

}
return verticalNametoPrimarySalesRepList;
}

 

I am pretty new to APEX and with help wrote a trigger to auto-update a lookup field based on selecting a value on a picklist field on the account object. It works fine on the Account object.  Now I am trying to replictae it on a custom object and the code below is giving me errors.

 

Error: Compile Error: unexpected token: 'Map" at line 1 column 14



public static Map<String, List<Primary_Sales_Rep__c>> filterPrimarySalesRepsWithChangedVerticals(List<Primary_Sales_Rep__c> incomingPrimarySalesReps,
Map<Id, PrimarySalesRep__c>oldPrimarySalesRepIdToOldPrimarySalesRep)
{

Map<String, List<PrimarySalesRep__c>> verticalNametoPrimarySalesRepList = new Map<String, List<PrimarySalesRep__c>>();

//For all PrimarySalesRep that were sent to out Trigger
for(PrimarySalesRep__c incomingPrimarySalesRep : incomingPrimarySalesReps)
{
//Change conditions
//1.Vertical is now being set
//2. Vertical is being changed

Boolean isChanged
Boolean isInsert - oldPrimarySalesRepIdToOldPrimarySalesRep == null;
PrimarySalesRep__c oldPrimarySalesRep = isInsert ? null : oldPrimarySalesRepIdToOldPrimarySalesRep.get(incomingPrimarySalesRep.Id);

isChanged = (( isInsert && incomingPrimarySalesRep__c.Vertical_Major__c != null)
||(!isInsert && oldPrimarySalesRep__c.Vertical_Major__c != incomingPrimarySalesRep__c.Vertical_Major__c));

if(isChanged)
{
if(!verticalNameToPrimarySalesRepList.containsKey( incomingPrimarySalesRep__c.Vertical_Major__c))
verticalNameToPrimarySalesrepList.put(incomingPrimarySalesRep__c.Vertical_Major__c, new List<PrimarySalesRep__c>));

verticalNameToPrimarySalesrepList.get( incomingPrimarySalesrep__c.Vertical_Major__c).add(incomingPrimarySalesrep__c);
}

}
return verticalNametoPrimarySalesRepList;
}

 

I am pretty new to APEX and with help wrote a trigger to auto-update a lookup field based on selecting a value on a picklist field on the account object. Now I am trying to replictae it on a custom object and the code below is giving me errors. 

Error: Compile Error: unexpected token: 'Map" at line 1 column 14

 

public static Map<String, List<Primary_Sales_Rep__c>> filterPrimarySalesRepsWithChangedVerticals(List<Primary_Sales_Rep__c> incomingPrimarySalesReps,
Map<Id, PrimarySalesRep__c>oldPrimarySalesRepIdToOldPrimarySalesRep)
{

Map<String, List<PrimarySalesRep__c>> verticalNametoPrimarySalesRepList = new Map<String, List<PrimarySalesRep__c>>();

//For all PrimarySalesRep that were sent to out Trigger
for(PrimarySalesRep__c incomingPrimarySalesRep : incomingPrimarySalesReps)
{
//Change conditions
//1.Vertical is now being set
//2. Vertical is being changed

Boolean isChanged
Boolean isInsert - oldPrimarySalesRepIdToOldPrimarySalesRep == null;
PrimarySalesRep__c oldPrimarySalesRep = isInsert ? null : oldPrimarySalesRepIdToOldPrimarySalesRep.get(incomingPrimarySalesRep.Id);

isChanged = (( isInsert && incomingPrimarySalesRep__c.Vertical_Major__c != null)
||(!isInsert && oldPrimarySalesRep__c.Vertical_Major__c != incomingPrimarySalesRep__c.Vertical_Major__c));

if(isChanged)
{
if(!verticalNameToPrimarySalesRepList.containsKey( incomingPrimarySalesRep__c.Vertical_Major__c))
verticalNameToPrimarySalesrepList.put(incomingPrimarySalesRep__c.Vertical_Major__c, new List<PrimarySalesRep__c>));

verticalNameToPrimarySalesrepList.get( incomingPrimarySalesrep__c.Vertical_Major__c).add(incomingPrimarySalesrep__c);
}

}
return verticalNametoPrimarySalesRepList;
}