0

Can anyone please help me with the code below and why I am getting a null exception

public with sharing class activitiesdashboard {
    public list<Transport__c> activities {get; set;}
    public List<Trip_Activity__c> internalActivities {get; set;}
    public set<Id> actIds;
    public timeZone tz {get;set;}
    public string location {get;set;}
    public datetime refreshDate {get;set;}
    public Id taId;
    public List<Id> IdList;

    public activitiesdashboard() {
        tz = UserInfo.getTimeZone();
        location = apexpages.currentPage().getparameters().get('Site');
        activitydetails(); 
        internalActivityDetails();
    } 

    public void internalActivityDetails(){
        //retrieve the data required
        string recordtypecontains = '%'+location+'%';
        internalActivities = [select Id,trip__r.Group_Name__c,trip__r.Group_SYCO_ID__c,Patron_ID__c,Patron_Name_E__c,Activity_Type__c,Car__c,
                   start_time__c,pax__c,venue__c,pickup_time__c,end_time__c,Host__r.name,trip__r.Patron_Type__c
                      from Trip_Activity__c where recordtype.name LIKE :recordtypecontains 
                      order by start_time__c asc limit 10];
          for(integer i=0;i < internalActivities.size();i++)
           {
            taId =   internalActivities[i].id;  
            actIds.add(taId);
           }
   }
}
2
  • 4
    You know, it would be extremely helpful, not to mention polite, if you could specify what line number and WHERE in the code that line is that is throwing the error. It would go much quicker
    – Eric
    Commented Jul 22, 2016 at 6:57
  • @Eric Sorry I missed that, thanks for point it out, will make sure I include all the info next time.
    – user27749
    Commented Jul 25, 2016 at 6:12

2 Answers 2

3

you never instantiate the Set before you do this

actIds.add(taId);

Update your code to public set<Id> actIds = New Set<ID>();

1
  • Not that it's really publicly accessible with no getter...
    – Adrian Larson
    Commented Jul 22, 2016 at 10:50
1

You are just declaring the class variable actIds. You have to instantiate it before using. Add below line in your constructor.

actIds = new Set<Id>();

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .