You need to sign in to do that
Don't have an account?
Siva Sakthi
This is my controller here i got the error system null pointer exception. any body give your suggestion how to solve this error.
public with sharing class AssignWorklistController
{
string subject;
string description;
string EmailList;
public static Events__c Event {
get {
if (Event == Null || Event !=Null)
{
//String EventId =ApexPages.currentPage().getParameters().get('EventId');
//if(ApexPages.currentPage().getParameters().get('EventId') != null){
String EventId =String.escapeSingleQuotes(EncodingUtil.urlDecode(ApexPages.currentPage().getParameters().get('EventId'), 'UTF-8'));
if(EventId != '' && EventId != null )
{
try
{
Event=[Select Events__c.Name, Assigned_to__c,Event_Type__r.CatalogType__c, Assigned_to__r.Name, Description__c From Events__c WHERE Id=:EventId limit 1];
Event.Assigned_To__c=null;
//Event.Description__c=Null;
}
catch(exception e)
{
ApexPages.addMessages(e);
}
}
//}
}
return Event;
}
set;
}
public AssignWorklistController ()
{
}
public PageReference AssignEvent ()
{
if(Event!=null)
{
try {
Update Event;
system.debug('Event Updated==');
system.debug('Event Updated=='+Event.Assigned_to__c);
// User u = [select Id,email from User where Id=: Event.Assigned_to__c];
Staff__c s =[select Id, Email_Id__c from Staff__c where Relatedstaff__c =:Event.Assigned_to__c];
system.debug('s.Email======'+s.Email_Id__c );
system.debug('s.Id======'+s.Id);
system.debug('UserInfo.getUserEmail()======'+UserInfo.getUserEmail());
if(s.Email_Id__c != null){
EmailList ='email-list\nsagarcloudcrm@gmail.com\n'+UserInfo.getUserEmail()+'\n'+s.Email_Id__c;
system.debug('EmailList=='+EmailList);
subject = Event.Event_Type__r.CatalogType__c;
subject = subject+string.valueof(system.now());
system.debug('subject =='+subject );
if(Event.End_Date_Time__c != null){
description ='You had Assigned with an Event Named '+Event.Event_Type__r.CatalogType__c+' '+'Your End Date on Task is on'+Event.End_Date_Time__c ;
}else{
description ='You had Assigned with an Event Named '+Event.Event_Type__r.CatalogType__c;
}
// string Response = VerticalResponseAPIClient.SendVREmail(subject, EmailList, subject, UserInfo.getUserEmail(), description);
// system.debug('Response ==='+Response );
}
System.debug('vent.Assigned_to__r.Name========'+Event.Assigned_to__r.Name);
if(ApexPages.currentPage().getParameters().get('EventId') != null){
String EventId =String.escapeSingleQuotes(EncodingUtil.urlDecode(ApexPages.currentPage().getParameters().get('EventId'), 'UTF-8'));
if(EventId != '' && EventId != null)
{
Events__c E = [Select Events__c.Name, Assigned_to__c,Event_Type__r.CatalogType__c, Assigned_to__r.Name, Description__c From Events__c WHERE Id=:EventId limit 1];
System.debug('vent.Assigned_to__r.Name========'+E.Assigned_to__r.Name);
Task_List__c TL = new Task_List__c();
TL.Assigned_To__c = E.Assigned_to__r.Name;
TL.Created_By__c = UserInfo.getName();
TL.Description__c = E.Description__c;
TL.Status__c ='Pending';
TL.Subject__c = E.Event_Type__r.CatalogType__c ;
TL.Assigned_Date__c = DateTime.Now();
TL.UniqueKey__c = String.valueof(TL.Assigned_To__c+TL.Created_By__c +TL.Assigned_Date__c);
Insert TL;
Event.Task_UniqueKey__c = TL.UniqueKey__c;
Update Event;
System.debug('vent.Assigned_to__r.Name========'+E.Assigned_to__r.Name);
}
}
}
catch (Exception e)
{
ApexPages.addMessages(e);
}
}
//SendMail();
return null;
}
public PageReference SendMail()
{
system.debug('subject===='+subject);
system.debug('EmailList===='+EmailList);
system.debug('description===='+description);
if(subject != null && EmailList!=null && description != null){
string Response = VerticalResponseAPIClient.SendVREmail(subject, EmailList, subject, UserInfo.getUserEmail(), description);
system.debug('Response ==='+Response );
}
PageReference pageRef = new PageReference('/apex/WorkListView');
return pageRef;
}
public PageReference Cancel()
{
PageReference pageRef = new PageReference('/apex/WorkListView');
return pageRef;
}
}
Advance Thanks
Maheswar
System.NullPointerException: Argument cannot be null.
This is my controller here i got the error system null pointer exception. any body give your suggestion how to solve this error.
public with sharing class AssignWorklistController
{
string subject;
string description;
string EmailList;
public static Events__c Event {
get {
if (Event == Null || Event !=Null)
{
//String EventId =ApexPages.currentPage().getParameters().get('EventId');
//if(ApexPages.currentPage().getParameters().get('EventId') != null){
String EventId =String.escapeSingleQuotes(EncodingUtil.urlDecode(ApexPages.currentPage().getParameters().get('EventId'), 'UTF-8'));
if(EventId != '' && EventId != null )
{
try
{
Event=[Select Events__c.Name, Assigned_to__c,Event_Type__r.CatalogType__c, Assigned_to__r.Name, Description__c From Events__c WHERE Id=:EventId limit 1];
Event.Assigned_To__c=null;
//Event.Description__c=Null;
}
catch(exception e)
{
ApexPages.addMessages(e);
}
}
//}
}
return Event;
}
set;
}
public AssignWorklistController ()
{
}
public PageReference AssignEvent ()
{
if(Event!=null)
{
try {
Update Event;
system.debug('Event Updated==');
system.debug('Event Updated=='+Event.Assigned_to__c);
// User u = [select Id,email from User where Id=: Event.Assigned_to__c];
Staff__c s =[select Id, Email_Id__c from Staff__c where Relatedstaff__c =:Event.Assigned_to__c];
system.debug('s.Email======'+s.Email_Id__c );
system.debug('s.Id======'+s.Id);
system.debug('UserInfo.getUserEmail()======'+UserInfo.getUserEmail());
if(s.Email_Id__c != null){
EmailList ='email-list\nsagarcloudcrm@gmail.com\n'+UserInfo.getUserEmail()+'\n'+s.Email_Id__c;
system.debug('EmailList=='+EmailList);
subject = Event.Event_Type__r.CatalogType__c;
subject = subject+string.valueof(system.now());
system.debug('subject =='+subject );
if(Event.End_Date_Time__c != null){
description ='You had Assigned with an Event Named '+Event.Event_Type__r.CatalogType__c+' '+'Your End Date on Task is on'+Event.End_Date_Time__c ;
}else{
description ='You had Assigned with an Event Named '+Event.Event_Type__r.CatalogType__c;
}
// string Response = VerticalResponseAPIClient.SendVREmail(subject, EmailList, subject, UserInfo.getUserEmail(), description);
// system.debug('Response ==='+Response );
}
System.debug('vent.Assigned_to__r.Name========'+Event.Assigned_to__r.Name);
if(ApexPages.currentPage().getParameters().get('EventId') != null){
String EventId =String.escapeSingleQuotes(EncodingUtil.urlDecode(ApexPages.currentPage().getParameters().get('EventId'), 'UTF-8'));
if(EventId != '' && EventId != null)
{
Events__c E = [Select Events__c.Name, Assigned_to__c,Event_Type__r.CatalogType__c, Assigned_to__r.Name, Description__c From Events__c WHERE Id=:EventId limit 1];
System.debug('vent.Assigned_to__r.Name========'+E.Assigned_to__r.Name);
Task_List__c TL = new Task_List__c();
TL.Assigned_To__c = E.Assigned_to__r.Name;
TL.Created_By__c = UserInfo.getName();
TL.Description__c = E.Description__c;
TL.Status__c ='Pending';
TL.Subject__c = E.Event_Type__r.CatalogType__c ;
TL.Assigned_Date__c = DateTime.Now();
TL.UniqueKey__c = String.valueof(TL.Assigned_To__c+TL.Created_By__c +TL.Assigned_Date__c);
Insert TL;
Event.Task_UniqueKey__c = TL.UniqueKey__c;
Update Event;
System.debug('vent.Assigned_to__r.Name========'+E.Assigned_to__r.Name);
}
}
}
catch (Exception e)
{
ApexPages.addMessages(e);
}
}
//SendMail();
return null;
}
public PageReference SendMail()
{
system.debug('subject===='+subject);
system.debug('EmailList===='+EmailList);
system.debug('description===='+description);
if(subject != null && EmailList!=null && description != null){
string Response = VerticalResponseAPIClient.SendVREmail(subject, EmailList, subject, UserInfo.getUserEmail(), description);
system.debug('Response ==='+Response );
}
PageReference pageRef = new PageReference('/apex/WorkListView');
return pageRef;
}
public PageReference Cancel()
{
PageReference pageRef = new PageReference('/apex/WorkListView');
return pageRef;
}
}
Advance Thanks
Maheswar
String EventId =String.escapeSingleQuotes(EncodingUtil.urlDecode(ApexPages.currentPage().getParameters().get('EventId'), 'UTF-8'));
* Please look into the above line. And confirm that the URL contains the parameter "EventId" and has value to that parameter.
* Then get the "EventId" in the contstrutor as
Public Static String EventId;
public AssignWorklistController ()
{
EventId = ApexPages.currentPage().getParameters().get('EventId');
}
After this
Use this
String.escapeSingleQuotes(EncodingUtil.urlDecode(EventId, 'UTF-8'));
instead of
String.escapeSingleQuotes(EncodingUtil.urlDecode(ApexPages.currentPage().getParameters().get('EventId'), 'UTF-8'));
Please check with this idea and let me if it works.
Regards,
RajaDinakaran