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
NK ShaNK Sha 

Error: Compile Error: Missing ';' at 'Record' at line 10 column 21

I am facing this error :
Error: Compile Error: Missing ';' at 'Record' at line 10 column 21
______________________________________________________________
Class: 
  
    public with sharing class CreateReplyCntrl
{
    public String body              {get;set;}
    public String ticektId          {get;set;}
    public List<Account> pAcc        {get;set;}
    public Account pAccountNew       {get;set;}
    public RemoteAuth__c remoAuth   {get;set;}
    public String requestId         {get;set;}
    public String key               {get;set;}
    public Case fd          {get;set;}
    public String note              {get;set;}
    public boolean noteVar          {get;set;}
    public String recTypeId;
    
    
    public CreateReplyCntrl(ApexPages.StandardController controller) {
        fd=new Case ();
        ticektId = String.escapesinglequotes(System.currentPageReference().getParameters().get('id'));
        note= System.currentPageReference().getParameters().get('note');
        if(note!=null)note = String.escapesinglequotes(note);
        if(note!=null)
        noteVar=true;
        else
            noteVar=false;
        
        if (ticektId != null) {
            if(Schema.sObjectType.RecordType.isQueryable()&&Schema.sObjectType.RecordType.fields.Id.isaccessible())
            {
                recTypeId = [Select id from RecordType where sObjectType = 'Account' AND Name = 'Person Account' Limit 1].id;
            }
            if(Schema.sObjectType.Case.isQueryable()&&Schema.sObjectType.Case.fields.Ticket_Id__c.isaccessible()&&Schema.sObjectType.Case.fields.AccountId.isaccessible()&&Schema.sObjectType.Case.fields.Ticket_Status__c.isaccessible()&&Schema.sObjectType.Case.fields.Subject.isaccessible())
            fd= [Select AccountId, Subject, Account.PersonEmail,Ticket_Status__c,Ticket_Id__c from Case where id =:String.escapeSingleQuotes(ticektId)];
             else{
                        ApexPages.addMessage(new ApexPages.Message(ApexPages.severity.FATAL,'insufficient access'));
                        
        
                            }
            if(Schema.sObjectType.Account.isQueryable()&&Schema.sObjectType.Account.fields.id.isaccessible()&&Schema.sObjectType.Account.fields.PersonEmail.isaccessible()&&Schema.sObjectType.Account.fields.requestId__c .isaccessible()&&Schema.sObjectType.Account.fields.FirstName.isaccessible()
                &&Schema.sObjectType.Account.fields.LastName.isaccessible()&&Schema.sObjectType.Account.fields.RecordTypeId.isaccessible())
            pAcc = [Select id,PersonEmail, requestId__c, FirstName, LastName from Account where id = :fd.AccountId AND RecordTypeId =: recTypeId Limit 1];
             else{
                    ApexPages.addMessage(new ApexPages.Message(ApexPages.severity.FATAL,'insufficient access'));
                  }
            requestId = pAcc[0].requestId__c;
            pAccountNew = pAcc[0];
        }
        List<RemoteAuth__c> remoAuthList=new List<RemoteAuth__c>();

        if(Schema.sObjectType.RemoteAuth__c.isQueryable()&&Schema.sObjectType.RemoteAuth__c.fields.fd_Apikey__c.isaccessible()&&Schema.sObjectType.RemoteAuth__c.fields.fd_Endpoint__c .isaccessible())
        remoAuthList = [SELECT fd_Apikey__c, fd_Endpoint__c FROM RemoteAuth__c limit 1];
         else{
                        ApexPages.addMessage(new ApexPages.Message(ApexPages.severity.FATAL,'insufficient access'));
                       
        
                            }
        if (remoAuthList != null && !remoAuthList.isEmpty()) {
            remoAuth = remoAuthList.get(0);
        }
    }
    
    public pageReference createReply(){
        if (remoAuth != null) {
            if (String.isBlank(body)) {
                ApexPages.addMessage(new ApexPages.Message(ApexPages.severity.error, 'Please Provide Body of the Reply !'));
                return null;
            }else {
                String endPointUrl = remoAuth.fd_Endpoint__c;
                if(!noteVar){
                    endPointUrl =endPointUrl +'/'+fd.Ticket_Id__c+'/reply';
                }
                else{
                    endPointUrl =endPointUrl +'/'+fd.Ticket_Id__c+'/notes';
                }
                
                key = remoAuth.fd_Apikey__c;
                HttpRequest req = new HttpRequest();
                req.setMethod('POST');
                req.setEndpoint(endPointUrl);
                body=body.replace('\"','');
                String body1 = '{ "body": "' + body + '","user_id":'+Decimal.valueOf(requestId)+'}';
                 body1= body1.replaceAll('\r\n', ' ');
                body1= body1.replaceAll('\n', ' ');
                body1= body1.replaceAll('\r', ' ');
                System.debug('#### body = '+body1);
                req.setBody(body1);
                req.setHeader('Content-Type', 'application/json');
                Blob headerValue = Blob.valueOf(key + ':' + 'X');
                String authorizationHeader = 'Basic ' + EncodingUtil.base64Encode(headerValue);
                req.setHeader('Authorization', authorizationHeader);
                
                try {
                    Http h = new Http();
                    HttpResponse res = h.send(req);
                    if (res.getStatusCode() == 201) {
                        System.debug('#### Reply Created ');
                    }
                    else{
                        ApexPages.addMessage(new ApexPages.Message(ApexPages.severity.error, 'Error while communicating with Freshdesk API:'+res.getStatusCode()));
                        return null;
                        
                    }
                    
                }catch (System.CalloutException e) {
                    if (e.getMessage().startsWith('Unauthorized endpoint')) {
                        ApexPages.addMessage(new ApexPages.Message(ApexPages.severity.error, 'Before using the Freshdesk API, an administrator must go to Setup =>' +
                        'Security Control => Remote Site Settings and add the following endpoint:' + endPointUrl.subStringBefore('/api/')));
                        
                    } else {
                        ApexPages.addMessage(new ApexPages.Message(ApexPages.severity.error, 'Error while communicating with FreshdeskAPI :' + e.getMessage()));
                    }
                    System.debug(e.getMessage());
                    return null;
                }
                
                PageReference pg = new PageReference('/apex/FreshdeskAction?id='+pAccountNew.id);
                pg.setRedirect(false);
                return pg;
            }
        } else {
            ApexPages.addMessage(new ApexPages.Message(ApexPages.severity.error, 'Authenticate Freshdesk before creating a new Ticket'));
            return null;
        }
    }
    
    public pagereference Cancel(){
        PageReference pageRef = new PageReference('/apex/FreshdeskAction?id=' +pAccountNew.id);
        pageRef.setRedirect(true);
        return pageRef;
    }
}


_________________________________
Test Class


//created on Nov 26, 2018 for CreateReplyCntrl apex class

@isTest
public class CreateReplyCntrlTest{

   static testMethod void CreateReplyCntrlTestMethod(){
   
        test.setCurrentPage(page.ReplyEntry);
         Account Acc = new Account();
        Acc.Account Record Type = 'Person Account';
        Acc.First Name = 'Astrea";
        Acc.LastName = 'Tester';
        Acc.Email = 'xyz@abc.com';
        Acc.RequestId__c = '17000211719';
        insert Acc;
        System.assertNotEquals(Acc.id,null);
        
        RemoteAuth__c Rauth=new RemoteAuth__c();
        Rauth.fd_Apikey__c='W60qxFvhdO3WkxW3USQb';
        Rauth.fd_Endpoint__c='https://astreait2.freshdesk.com/api/v2/tickets/53/notes';
        insert Rauth;
        System.assertNotEquals(Rauth.id,null);
        
        Case c = new case();
        c.Case Number = 00001035;
        c.Priority = 'Low';
        c.Ticket_Status__c = 'Working';
        c.Ticket_Id__c = 'Tst-1001';
        c.Subject = 'Test Case';
        inser c;
        system.assertNotEquals(c.id,null);
        
        test.starttest();
        System.currentPageReference().getParameters().put('id',c.id);
        CreateReplyCntrl ext = new CreateReplyCntrl(new ApexPages.StandardController(c));
        ext.createReply();
        Test.setMock(HttpCalloutMock.class, new CreateReplyCntrlReplyMockTest());
        ext.body = 'Testing';        
        ext.createReply();
        
        c.Ticket_Status__c ='Waiting on customer';
        c.Ticket_Priority__c='High';
        update c;
        System.currentPageReference().getParameters().put('id',c.id);
        CreateReplyCntrl ext1 = new CreateReplyCntrl(new ApexPages.StandardController(c));
        ext1.createReply();
        System.currentPageReference().getParameters().put('note','true');
        Test.setMock(HttpCalloutMock.class, new CreateReplyCntrlNotesMockTest());

        CreateReplyCntrl ext2 = new CreateReplyCntrl(new ApexPages.StandardController(tk));
        ext2.notevar=true;
        ext2.createReply();
        ext2.Cancel();
 
        test.stoptest();
    }

}
Khan AnasKhan Anas (Salesforce Developers) 
Hi,

Greetings to you!

You are getting this error because in test class you are using one single quote and one double quote on this line: Acc.First Name = 'Astrea";

Change this line to: Acc.FirstName = 'Astrea';

Test Class:
//created on Nov 26, 2018 for CreateReplyCntrl apex class

@isTest
public class CreateReplyCntrlTest{

   static testMethod void CreateReplyCntrlTestMethod(){
   
        test.setCurrentPage(page.ReplyEntry);
         Account Acc = new Account();
        Acc.AccountRecordType = 'Person Account';
        Acc.FirstName = 'Astrea';
        Acc.LastName = 'Tester';
        Acc.Email = 'xyz@abc.com';
        Acc.RequestId__c = '17000211719';
        insert Acc;
        System.assertNotEquals(Acc.id,null);
        
        RemoteAuth__c Rauth=new RemoteAuth__c();
        Rauth.fd_Apikey__c='W60qxFvhdO3WkxW3USQb';
        Rauth.fd_Endpoint__c='https://astreait2.freshdesk.com/api/v2/tickets/53/notes';
        insert Rauth;
        System.assertNotEquals(Rauth.id,null);
        
        Case c = new case();
        c.Case Number = 00001035;
        c.Priority = 'Low';
        c.Ticket_Status__c = 'Working';
        c.Ticket_Id__c = 'Tst-1001';
        c.Subject = 'Test Case';
        inser c;
        system.assertNotEquals(c.id,null);
        
        test.starttest();
        System.currentPageReference().getParameters().put('id',c.id);
        CreateReplyCntrl ext = new CreateReplyCntrl(new ApexPages.StandardController(c));
        ext.createReply();
        Test.setMock(HttpCalloutMock.class, new CreateReplyCntrlReplyMockTest());
        ext.body = 'Testing';        
        ext.createReply();
        
        c.Ticket_Status__c ='Waiting on customer';
        c.Ticket_Priority__c='High';
        update c;
        System.currentPageReference().getParameters().put('id',c.id);
        CreateReplyCntrl ext1 = new CreateReplyCntrl(new ApexPages.StandardController(c));
        ext1.createReply();
        System.currentPageReference().getParameters().put('note','true');
        Test.setMock(HttpCalloutMock.class, new CreateReplyCntrlNotesMockTest());

        CreateReplyCntrl ext2 = new CreateReplyCntrl(new ApexPages.StandardController(tk));
        ext2.notevar=true;
        ext2.createReply();
        ext2.Cancel();
 
        test.stoptest();
    }

}

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Thanks and Regards,
Khan Anas
NK ShaNK Sha
I am using the single quore As well But facing the same problem at
@isTest
public class CreateReplyCntrlTest{

   static testMethod void CreateReplyCntrlTestMethod(){
   
        test.setCurrentPage(page.ReplyEntry);
         Account Acc = new Account();
        Acc.Account Record Type = 'Person Account';
        Acc.First Name = 'Test';
        Acc.LastName = '123';
        Acc.Email = 'xyz@abc.com';
        Acc.RequestId__c = '17000211719';
        insert Acc;
        System.assertNotEquals(Acc.id,null);
        
        RemoteAuth__c Rauth=new RemoteAuth__c();
        Rauth.fd_Apikey__c='W60qxFvhdO3WkxW3USQb';
        Rauth.fd_Endpoint__c='https://abc2.freshdesk.com/api/v2/tickets/53/notes';
        insert Rauth;
        System.assertNotEquals(Rauth.id,null);
        
        Case c = new case();
        c.Case Number = 00001035;
        c.Priority = 'Low';
        c.Ticket_Status__c = 'Working';
        c.Ticket_Id__c = 'Tst-1001';
        c.Subject = 'Test Case';
        inser c;
        system.assertNotEquals(c.id,null);
        
        test.starttest();
        System.currentPageReference().getParameters().put('id',c.id);
        CreateReplyCntrl ext = new CreateReplyCntrl(new ApexPages.StandardController(c));
        ext.createReply();
        Test.setMock(HttpCalloutMock.class, new CreateReplyCntrlReplyMockTest());
        ext.body = 'Testing';        
        ext.createReply();
        
        c.Ticket_Status__c ='Waiting on customer';
        c.Ticket_Priority__c='High';
        update c;
        System.currentPageReference().getParameters().put('id',c.id);
        CreateReplyCntrl ext1 = new CreateReplyCntrl(new ApexPages.StandardController(c));
        ext1.createReply();
        System.currentPageReference().getParameters().put('note','true');
        Test.setMock(HttpCalloutMock.class, new CreateReplyCntrlNotesMockTest());

        CreateReplyCntrl ext2 = new CreateReplyCntrl(new ApexPages.StandardController(tk));
        ext2.notevar=true;
        ext2.createReply();
        ext2.Cancel();
 
        test.stoptest();
    }

}
Khan AnasKhan Anas (Salesforce Developers) 
Remove the space also from FirstName
Acc.FirstName = 'Astrea';

Also remove space from 
Acc.AccountRecordType = 'Person Account';