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
Silabs AdminSilabs Admin 

Save error: unexpected token: '='

this is bizarre.. 

 

I have a sample class to test Sales Team:

 

OpportunityTeamMember member = new OpportunityTeamMember();
member.OpportunityId = '006Z0000002xxxxxx';
member.UserId = '005Z00000xxxxxx';
member.TeamMemberRole = 'FAE';
	 
insert member;

 

I get error: Save error: unexpected token: '=' on line 2,3,and 4. Why is this happening? This is driving me crazy.. 

Best Answer chosen by Admin (Salesforce Developers) 
SuperfellSuperfell

Your code needs to be inside a function, right now you have it just in the class directly.

All Answers

MandyKoolMandyKool

Hi,

 

The code looks ok to me. I am assuming that you have written this code either in "Developer Console" or inside your Test class.

 

Have you copied the code from somewhere? You can remove the '=' and type it again and try to save.

 

 

Silabs AdminSilabs Admin

Yes, I did copy paste, my first instict was that too, and I deleted = and typed in again. Not sure what is causing the issue.. this is so frustrating. 

Thanks for the comment.. 

MandyKoolMandyKool

If possible you can paste your entire code here!!

Silabs AdminSilabs Admin

here you go, 

 

public with sharing class TransferBusiness {
	
	OpportunityTeamMember member = new OpportunityTeamMember();
	member.OpportunityId = '006xxxxxxxxxxxxx';
	member.UserId = '005Z0000000xxxxx';
	member.TeamMemberRole = 'FAE';
	 
	insert member;
	 
	// get all of the team members' sharing records
	List<OpportunityShare> shares = [select Id, OpportunityAccessLevel, RowCause from OpportunityShare where OpportunityId = '006Z0000002a0vXIAQ' and RowCause = 'Team'];
	 
	// set all team members access to read/write
	for (OpportunityShare share : shares) 
	  share.OpportunityAccessLevel = 'Edit';
	 
	update shares;

}

 Not sure what is going on.. if I comment out 4,5, and 6, it gives me new error "right patenthesis missing }".. looks like I am missing something, not sure what. 

SuperfellSuperfell

Your code needs to be inside a function, right now you have it just in the class directly.

This was selected as the best answer
Silabs AdminSilabs Admin

Thanks. I feel like banging my head against the wall.