+ Start a Discussion

Error: Compile Error: unexpected token: 'Map' at line 15 column 0

I am not familiar with maps so any help is greatly appreciated!  Can anyone help me understand why I am getting the below error on the below code??  Please note that line 15 is "Map idsCoverage = new Map();"


Thanks in advance for any help!!!


Error: Compile Error: unexpected token: 'Map' at line 15 column 0



//This trigger includes all financial rollups to the Coverage

trigger UpdateRollupsToCoverage on Claim__c (after update)
//Define variables
double sumCoverageTotalExpenseOS = 0.0;
double sumCoverageTotalExpensePD = 0.0;
double sumCoverageTotalLegalOS = 0.0;
double sumCoverageTotalLegalPD = 0.0;
double sumCoverageTotalIndemnityOS = 0.0;
double sumCoverageTotalIndemnityPD = 0.0;
Coverage__c [] coveragesToUpdate = new Coverage__c[]{};

Map idsCoverage = new Map();

Claim__c [] teNew = trigger.new;
for(Claim__c te : teNew)
for (Coverage__c claimCoverage : [select Id, Name, Coverage_Total_Expense_O_S__c from Coverage__c where Id = :te.Claim_Coverage__c])

//Sum all the claimCoverage entries
//Total Expense OS
for (Claim__c expenseOSs: [select Id, Expense_OS__c from Claim__c where Claim_Coverage__c = :claimCoverage.id])
{sumCoverageTotalExpenseOS += expenseOSs.Expense_OS__c;}
claimCoverage.Coverage_Total_Expense_O_S__c = sumCoverageTotalExpenseOS;
//Total Expense PD
for (Claim__c expensePDs: [select Id, Expense_PD__c from Claim__c where Claim_Coverage__c = :claimCoverage.id])
{sumCoverageTotalExpensePD += expensePDs.Expense_PD__c;}
claimCoverage.Coverage_Total_Expense_PD__c = sumCoverageTotalExpensePD;
//Total Legal OS
for (Claim__c legalOSs: [select Id, Legal_OS__c from Claim__c where Claim_Coverage__c = :claimCoverage.id])
{sumCoverageTotalLegalOS += legalOSs.Legal_OS__c;}
claimCoverage.Coverage_Total_Legal_O_S__c = sumCoverageTotalLegalOS;
//Total Legal PD
for (Claim__c legalPDs: [select Id, Legal_PD__c from Claim__c where Claim_Coverage__c = :claimCoverage.id])
{sumCoverageTotalLegalPD += legalPDs.Legal_PD__c;}
claimCoverage.Coverage_Total_Legal_PD__c = sumCoverageTotalLegalPD;
//Total Indemnity OS
for (Claim__c indemnityOSs: [select Id, Indemnity_OS__c from Claim__c where Claim_Coverage__c = :claimCoverage.id])
{sumCoverageTotalIndemnityOS += indemnityOSs.Indemnity_OS__c;}
claimCoverage.Coverage_Total_Indemnity_O_S__c = sumCoverageTotalIndemnityOS;
//Total Indemnity PD
for (Claim__c indemnityPDs: [select Id, Indemnity_PD__c from Claim__c where Claim_Coverage__c = :claimCoverage.id])
{sumCoverageTotalIndemnityPD += indemnityPDs.Indemnity_PD__c;}
claimCoverage.Coverage_Total_Indemnity_PD__c = sumCoverageTotalIndemnityPD;

idsCoverage.put(claimCoverage.id, claimCoverage.id);
//add claimCoverage to list to be updated outside of the loop only if coverage is Unique
//If coverage exists then update separately

update claimCoverage;


//commit the changes to Salesforce
update coveragesToUpdate;}

Naidu PothiniNaidu Pothini

Thanks for your help on this! 


Unfortunately, I am still looking for some help.  When I add that into the code, I get the error:



Error: Compile Error: Method does not exist or incorrect signature: [MAP<Id,Id>].containsId(Id) at line 52 column 5


line 52 shows:




any ideas on why this is an issue?




Naidu PothiniNaidu Pothini

Map<Key, Value> will hold a value for the key we specify.


Map<Id, Id> xMap = new Map<Id,Id>();


xMap.put('1', 'A001');

xMap.put('2', 'A002');


so when ever you use. xMap.get('1')... it will return you the value for the key "1", so you get the A001 Id.


you cannot use contains() method on Maps.. try using ContainsKey() method instead.




you can find what are all the methods you can use on a map in the above link.


Please go through it.