+ Start a Discussion
vijayabhaskarareddyvijayabhaskarareddy 

Error: Compile Error: line 15:42 no viable alternative at character '‘' at line 15 column 42

can anyone help me on this task .

public with sharing class TrainingCasefilter {

    public id accRecId;
    private integer totalRecs = 0;
private integer OffsetSize = 0;
private integer LimitSize= 10;
   

    public TrainingCasefilter(ApexPages.StandardController controller) {

    accRecId = [select id from account where id = :ApexPages.currentPage().getParameters().get('id')].id;
    totalRecs = [select count() from case where accountID= :accRecId];

    }

    List<case> trainingCases;

    public List<case> getTrainingCases() {
        if(accRecId != null) {
        trainingCases= [SELECT Id, Contact.name, recordtype.id, casenumber, subject, priority, createddate, status, createdbyid
                        FROM Case
                        WHERE RecordType.Name ='Training' AND account.id=:accRecId LIMIT :LimitSize OFFSET :OffsetSize];
        }
    return trainingCases;
    }    
    
    public void FirstPage()
{
OffsetSize = 0;
}
public void previous()
{
OffsetSize = OffsetSize – LimitSize;
}public void next()
{
OffsetSize = OffsetSize + LimitSize;
}public void LastPage()
{
OffsetSize = totalrecs – math.mod(totalRecs,LimitSize);
}
public boolean getprev()
{
if(OffsetSize == 0)
return true;
else
return false;
}
public boolean getnxt()
{
if((OffsetSize + LimitSize) > totalRecs)
return true;
else
return false;
}

}
Best Answer chosen by vijayabhaskarareddy
BALAJI CHBALAJI CH
Hi Vijayabhaskarareddy,

Not sure what is the exact issue causing the error., but I modified your code  bit and able to save successfully. Please find below modified code:
public with sharing class TrainingCasefilter {
    
    public id accRecId;
    private integer totalRecs = 0;
    private integer OffsetSize = 0;
    private integer LimitSize= 10;
    
    public TrainingCasefilter(ApexPages.StandardController controller) {
        
        accRecId = [select id from account where id = :ApexPages.currentPage().getParameters().get('id')].id;
        totalRecs = [select count() from case where accountID= :accRecId];
        
    }
    
    List<case> trainingCases;
    
    public List<case> getTrainingCases() {
        if(accRecId != null) {
            trainingCases= [SELECT Id, Contact.name, recordtype.id, casenumber, subject, priority, createddate, status, createdbyid
                            FROM Case
                            WHERE RecordType.Name ='Training' AND account.id=:accRecId LIMIT :LimitSize OFFSET :OffsetSize];
        }
        return trainingCases;
    }    
    
    public void FirstPage()
    {
        OffsetSize = 0;
    }
    public void previous()
    {
        OffsetSize = OffsetSize - LimitSize;
    }public void next()
    {
        OffsetSize = OffsetSize + LimitSize;
    }public void LastPage()
    {
        OffsetSize = totalrecs - math.mod(totalRecs,LimitSize);
    }
    public boolean getprev()
    {
        if(OffsetSize == 0)
            return true;
        else
            return false;
    }
    public boolean getnxt()
    {
        if((OffsetSize + LimitSize) > totalRecs)
            return true;
        else
            return false;
    }
}

Let me know if that works for you. 

Best Regards,
BALAJI

All Answers

BALAJI CHBALAJI CH
Hi Vijayabhaskarareddy,

Not sure what is the exact issue causing the error., but I modified your code  bit and able to save successfully. Please find below modified code:
public with sharing class TrainingCasefilter {
    
    public id accRecId;
    private integer totalRecs = 0;
    private integer OffsetSize = 0;
    private integer LimitSize= 10;
    
    public TrainingCasefilter(ApexPages.StandardController controller) {
        
        accRecId = [select id from account where id = :ApexPages.currentPage().getParameters().get('id')].id;
        totalRecs = [select count() from case where accountID= :accRecId];
        
    }
    
    List<case> trainingCases;
    
    public List<case> getTrainingCases() {
        if(accRecId != null) {
            trainingCases= [SELECT Id, Contact.name, recordtype.id, casenumber, subject, priority, createddate, status, createdbyid
                            FROM Case
                            WHERE RecordType.Name ='Training' AND account.id=:accRecId LIMIT :LimitSize OFFSET :OffsetSize];
        }
        return trainingCases;
    }    
    
    public void FirstPage()
    {
        OffsetSize = 0;
    }
    public void previous()
    {
        OffsetSize = OffsetSize - LimitSize;
    }public void next()
    {
        OffsetSize = OffsetSize + LimitSize;
    }public void LastPage()
    {
        OffsetSize = totalrecs - math.mod(totalRecs,LimitSize);
    }
    public boolean getprev()
    {
        if(OffsetSize == 0)
            return true;
        else
            return false;
    }
    public boolean getnxt()
    {
        if((OffsetSize + LimitSize) > totalRecs)
            return true;
        else
            return false;
    }
}

Let me know if that works for you. 

Best Regards,
BALAJI
This was selected as the best answer
vijayabhaskarareddyvijayabhaskarareddy
@ Balaji

Could u please let me know  my mistake
BALAJI CHBALAJI CH
The only changes I did in your code was at lines 32 and 38., for subtracting, you used Hyphen (-) instead of minus (-).
Both seems to be same but different characters.