You need to sign in to do that
Don't have an account?
Support 3743
I can't understand why these errors occur: attempt to de-reference null object & assertion failed
I'm trying to deploy something like this:
public class Send {
public Send(){
}
public static Messaging.SingleEmailMessage createEmail(
String SenderName, Id TemplateId, Id ObjectId, Id WhatId)
{
Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
email.setTargetObjectId(ObjectId);
email.setTemplateId(TemplateId);
email.setWhatId(WhatId);
email.setSenderDisplayName(SenderName);
return email;
}
public static void MessageSent() {
/* Create a list of email objects */
Messaging.SingleEmailMessage [] emails = new Messaging.SingleEmailMessage[]{};
/* Get a list of contacts */
List<Contact> c = [SELECT Name, Id, AccountId
FROM Contact
WHERE Email != null AND Email != '' ];
/* Find the size of all the contacts */
Integer ContactSize = c.size();
/* Locate the email template being used */
EmailTemplate et = [SELECT id
FROM EmailTemplate
WHERE Name = 'CAF VF'];
/* Iterate through the list of contacts and send email to each */
for (Integer i = 0; i < ContactSize; i++){
Messaging.SingleEmailMessage temp = createEmail('Report', et.id, c[i].Id, c[i].AccountId);
emails.add(temp);
}
try{
Messaging.sendEmail(emails);
} catch (Exception e) {
System.debug('The following exception has occured: ' + e.getMessage());
}
}
}
I get the following errors:
- System.NullPointerException: Attempt to de-reference a null object, Stack Trace: Class.MassUpdateSimpleControllerTest.testOpportunityInRelatedList: line 148, column 1
- System.AssertException: Assertion Failed, Stack Trace: Class.Milestone1_GettingStartedController.testGettingStartedProject: line 239, column 1
- System.NullPointerException: Attempt to de-reference a null object, Stack Trace: Class.Milestone1_GettingStartedController.getInitialSettingsWithoutSave: line 190, column 1 Class.Milestone1_GettingStartedController.testGetSettings: line 211, column 1
I have no idea how to fix this. Help me, please!
public class Send {
public Send(){
}
public static Messaging.SingleEmailMessage createEmail(
String SenderName, Id TemplateId, Id ObjectId, Id WhatId)
{
Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
email.setTargetObjectId(ObjectId);
email.setTemplateId(TemplateId);
email.setWhatId(WhatId);
email.setSenderDisplayName(SenderName);
return email;
}
public static void MessageSent() {
/* Create a list of email objects */
Messaging.SingleEmailMessage [] emails = new Messaging.SingleEmailMessage[]{};
/* Get a list of contacts */
List<Contact> c = [SELECT Name, Id, AccountId
FROM Contact
WHERE Email != null AND Email != '' ];
/* Find the size of all the contacts */
Integer ContactSize = c.size();
/* Locate the email template being used */
EmailTemplate et = [SELECT id
FROM EmailTemplate
WHERE Name = 'CAF VF'];
/* Iterate through the list of contacts and send email to each */
for (Integer i = 0; i < ContactSize; i++){
Messaging.SingleEmailMessage temp = createEmail('Report', et.id, c[i].Id, c[i].AccountId);
emails.add(temp);
}
try{
Messaging.sendEmail(emails);
} catch (Exception e) {
System.debug('The following exception has occured: ' + e.getMessage());
}
}
}
I get the following errors:
- System.NullPointerException: Attempt to de-reference a null object, Stack Trace: Class.MassUpdateSimpleControllerTest.testOpportunityInRelatedList: line 148, column 1
- System.AssertException: Assertion Failed, Stack Trace: Class.Milestone1_GettingStartedController.testGettingStartedProject: line 239, column 1
- System.NullPointerException: Attempt to de-reference a null object, Stack Trace: Class.Milestone1_GettingStartedController.getInitialSettingsWithoutSave: line 190, column 1 Class.Milestone1_GettingStartedController.testGetSettings: line 211, column 1
I have no idea how to fix this. Help me, please!
Support 3743
@Rahul.Mishra sorry to bug you but I really need help on this! Thank you so much!