You need to sign in to do that
Don't have an account?
Skottyp
Initial term of expression must be a concrete
I've been working on this a while and I am close, but running into this error:
Line 28 is the error. I have written in 10 different ways and am not sure where I am making the mistake. I am just trying to get 1 map to work and then the other should be the same code. Thanks!
Thanks for the help!
trigger AssignDistSales2 on Distributor_Sales__c (before insert, before update) { //get set of 3 digit zips from Distributor Sales to be inserted or updated List<String> DSzip = new List<String>(); for(Distributor_Sales__c ds : Trigger.new) { if(ds.ZipCode__c.length() == 5) { DSzip.add(ds.X3_Digit_Zip__c); //system.debug('5 digits - ' + ds.X3_Digit_Zip__c); } else { DSzip.add('0'+ ds.X3_Digit_Zip__c); //system.debug('4 digits - ' + ds.X3_Digit_Zip__c); } } //list of territories needed to map to Distributor Sales zip Map<String,Territory__c> terrMap = new Map<String, Territory__c> ([SELECT X3_Digit_Zip__c, Sales_Rep__c FROM Territory__c WHERE X3_Digit_Zip__c in :DSzip]); Map<String,Territory__c> terrMap2 = new Map<String, Territory__c> ([SELECT X3_Digit_Zip__c, Sales_Rep_for_Later_Assignment__c FROM Territory__c WHERE X3_Digit_Zip__c in :DSzip]); system.debug('potentialTerr - ' + terrMap2); List<Distributor_Sales__c> currentDS = new List<Distributor_Sales__c>(); for(Distributor_Sales__c dsnew : DSzip) { dsnew.Sales_Rep_for_Later_Assignment__c = terrMap2.get(DSzip.X3_Digit_Zip__c).Sales_Rep_for_Later_Assignment__c; currentDS.add(dsnew); } update currentDS; }
Line 28 is the error. I have written in 10 different ways and am not sure where I am making the mistake. I am just trying to get 1 map to work and then the other should be the same code. Thanks!
Thanks for the help!
All Answers
The string in the map terrMap is not the 'X3_Digit_Zip__c'....its ID of that particular record.
I checked with same kind of query in org results below.
so in line 28 what ever you trying to do that wont get exist in the map.
Change your map query accordingly
Thanks,
pRAMODH.
08:23:27:287 USER_DEBUG [23]|DEBUG|potentialTerr - {a00m000000=Territory__c:{X3_Digit_Zip__c=100, Sales_Rep_for_Later_Assignment__c=003m000000, Id=a00m000000}, a00m000000=Territory__c:{X3_Digit_Zip__c=113, Sales_Rep_for_Later_Assignment__c=003m000000, Id=a00m000000},
I have this 3 digit zip on both my Territory Object and my Distributor Sales Object and I want to use this as a way to map the territory owner (Sales Rep) from the Territory to my Distributor Sales object. Does that make sense?
DistributionSales Object.Sales Rep = terrMap2.get( X3_Digit_Zip__c ).Sales_Rep_for_Later_Assignment__c;
Something like that!