You need to sign in to do that
Don't have an account?
Vigneshwaran Loganathan
Importing Calendar
Hi,
I am trying to add calender to My Dev Org with the help of one link.
But Im facing issue on Pageload funtion,
Its showing "Attempt to de-reference a null object" on campEvent.endString . But from Debud Log i can see records.
What could be the reason for this?
Thanks
Vignesh
I am trying to add calender to My Dev Org with the help of one link.
But Im facing issue on Pageload funtion,
public class CalendarExample_Controller { public Boolean includeMyEvents {get;set;} public list<calEvent> events {get;set;} //The calendar plugin is expecting dates is a certain format. We can use this string to get it formated correctly String dtFormat = 'EEE, d MMM yyyy HH:mm:ss z'; //constructor public CalendarExample_Controller() { //Default showing my events to on includeMyEvents = true; } public PageReference pageLoad() { events = new list<calEvent>(); //Get Contact's Birthdays for(Contact cont : [select Id, Birthdate, FirstName, LastName from Contact where Birthdate != null]){ //here we need to replace the birth year with the current year so that it will show up on this years calendar DateTime startDT = datetime.newInstance(Date.Today().Year(),cont.Birthdate.Month(), cont.Birthdate.Day()); calEvent bday = new calEvent(); bday.title = cont.FirstName + ' ' + cont.LastName + '\'s Birthday!'; bday.allDay = true; bday.startString = startDT.format(dtFormat); //Because this is an all day event that only spans one day, we can leave the send date null bday.endString = ''; bday.url = '/' + cont.Id; bday.className = 'event-birthday'; system.debug('>>>bday'+bday); events.add(bday); } //Get Campaigns for(Campaign camp : [select Id, Name, StartDate, EndDate from Campaign where IsActive = true]) { DateTime startDT = camp.StartDate; system.debug('>>>startDT'+startDT); DateTime endDT = camp.EndDate; calEvent campEvent = new calEvent(); campEvent.title = camp.Name; campEvent.allDay = true; campEvent.startString = startDT.format(dtFormat); campEvent.endString = endDT.format(dtFormat); campEvent.url = '/' + camp.Id; campEvent.className = 'event-campaign'; //system.debug('>>>11'+endDT.format(dtFormat)); events.add(campEvent); } return null; } public PageReference toggleMyEvents() { if(includeMyEvents){ includeMyEvents = false; } else{ includeMyEvents = true; } pageload(); return null; } //Class to hold calendar event data public class calEvent{ public String title {get;set;} public Boolean allDay {get;set;} public String startString {get;private set;} public String endString {get;private set;} public String url {get;set;} public String className {get;set;} } }
Its showing "Attempt to de-reference a null object" on campEvent.endString . But from Debud Log i can see records.
What could be the reason for this?
Thanks
Vignesh
Try to print And also try in a different browser and see.
Hope this helps you!
Thanks and Regards
Sandhya