You need to sign in to do that
Don't have an account?
CarlaMartinez.ax1388
Trigger - Auto-update lookup fields from picklist value on custom object
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; }
Is it trigger code or a static method in trigger/class ?
It's a method in a class