+ Start a Discussion
Leonard CadetLeonard Cadet 

Apex Code Error When running anonymous block: Unexpected token '<'.

When I run the below code I get the error I listetd in the title:

Unexpected token '<'.

I believe it is my syntax but I can't see a debug log that directs me to a line in my code that is listing the issue. 

Below is the code I am trying to run. 

List<CCMI__Milestone_Project__c> CCMIProject = 
    [SELECT 
    CCMI__Opportunity__c,
    Id 
    FROM CCMI__Milestone_Project__c WHERE id = a6X3D000000OVfGUAW
     ];

List<CCMI__Milestone_Task__c> CCMITask = 
    [SELECT 
    CCMI__Milestone_Project__c,
    Id,
    Name 
    FROM CCMI__Milestone_Task__c WHERE Project__c = a6X3D000000OVfGUAW 
     ];

List<CCMI__Milestone_Task__c> TempTask = 
    [SELECT 
    CCMI__Milestone_Project__c,
    Id,
    Name 
    FROM CCMI__Milestone_Task__c WHERE Project__c = a6X3D000000OVerUAG
     ];

List<Department_To_Task__c> DeptTask = 
    [SELECT 
    Id,
    Milestone_Task__c,
    Name 
    FROM Department_To_Task__c
     ];

List<Opportunity> Oppo = 
    [SELECT 
    Id 
    FROM Opportunity WHERE id = 0063D00000AudqdQAB
     ];

List<OpportunityTeamMember> OppoTeam = 
    [SELECT 
    Id,
    Name,
    OpportunityId,
    TeamMemberRole 
    FROM OpportunityTeamMember WHERE OpportunityId = 0063D00000AudqdQAB  
     ];

List<CCMI__Milestone_Assignment2__c> Assign =
    [SELECT CCMI__Assignee_Name__c,CCMI__Milestone_Task__c 
    FROM CCMI__Milestone_Assignment2__c     
    ];

     
    for(CCMI__Milestone_Task__c TT:TempTask){

        for (CCMI__Milestone_Task__c CT:CCMITask){

            for(Department_To_Task__c DT:DeptTask){

                for(OpportunityTeamMember OT:OppoTeam){

                    if(TT.Name == CT.Name && OT.TeamMemberRole == DT.Name )     
                    {
                        Assignment sign = new sign (
                        Assign.CCMI__Assignee_Name__c = OT.Name;
                        Assign.CCMI__Milestone_Task__c = CT.Id;
                        System.debug('** True **'); 
                       )
                        insert sign;
                    }
             }
          }
        }
      }



update Assign;

Best Answer chosen by Leonard Cadet
Colton WehkingColton Wehking
The IDs must be between single quotes

E.g.
List<OpportunityTeamMember> OppoTeam = 
    [SELECT 
    Id,
    Name,
    OpportunityId,
    TeamMemberRole 
    FROM OpportunityTeamMember WHERE OpportunityId = '0063D00000AudqdQAB'
     ];

 

All Answers

Leonard CadetLeonard Cadet
The IDs are hardcode for testing but dynamic SOQL will be used when I get this code into a button. 
Colton WehkingColton Wehking
The IDs must be between single quotes

E.g.
List<OpportunityTeamMember> OppoTeam = 
    [SELECT 
    Id,
    Name,
    OpportunityId,
    TeamMemberRole 
    FROM OpportunityTeamMember WHERE OpportunityId = '0063D00000AudqdQAB'
     ];

 
This was selected as the best answer
Leonard CadetLeonard Cadet
Thank you for such a quick response. I'll be closer attention to that.