function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ 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 =;
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 =])
{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 =])
{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 =])
{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 =])
{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 =])
{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 =])
{sumCoverageTotalIndemnityPD += indemnityPDs.Indemnity_PD__c;}
claimCoverage.Coverage_Total_Indemnity_PD__c = sumCoverageTotalIndemnityPD;

//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.

Mat JaggardMat Jaggard
The problem for me was that I named my variable `map` which apparently is not acceptable in my case but the error appears at the beginning of the line.

Map<String, List<QuoteResponse>> m; <-- fine

Map<String, List<QuoteResponse>> map; <-- error at the start of this line