You need to sign in to do that
Don't have an account?
SeattleSFDC
Deploying to Production Issues
Hello,
I'm having issues with deploying changes to Production, and the error messages I'm recieving is "System.NullPointerException: Attempt to de-reference a null object". Any ideas how to fix?
Test Failures:
approveDealRegVFTEST
Method NameTotal Time (ms)MessageStack Trace
|
RenewalNotificationControllerTEST
Method NameTotal Time (ms)MessageStack Trace
|
approveDealRegVFTest class Line 252:
String retURL = controller.save().getUrl();
approveDealRegVFTest class Line 482:
String retURL = controller.save().getUrl();
RenewalNotificationController class line 321:
private String mergeExistingFields(String text, Opportunity opp) {
Set<String> existingFields = opportunityFields.keySet();
for (String mergeField : existingFields) {
System.debug('mergeField = ' + mergeField);
Integer index = text.indexOf(mergeField);
while (index != -1) {
String fieldSoqlName = opportunityFields.get(mergeField);
String value = '';
if (fieldSoqlName.startsWith('Account')) {
Account a = opp.Account;
fieldSoqlName = fieldSoqlName.substring(8);
value = (String) a.get(fieldSoqlName); <-------LINE 321
}
RenewalNotificationController Class line 227:
//merge existing fields String subject = emailTemplate.Subject; subject = mergeExistingFields(subject, opp); <-----LINE 227
RenewalNotificationController Class line 177:
//create the merged email and add it array Messaging.SingleEmailMessage mail = mergeAndCreateMail(templateDetails, wrapper.getOpportunity()); <------LINE 177 mails.add(mail);
RenewalNotificationControllerTEST Test Class line 71:
controller.sendMail();
Make sure, the 'fieldSoqlName' field on Account is null.
In addition to Jia's remarks that point at flawed code, a larger issue is why this is happening in PROD and not in sandbox.
The most likely cause is your testmethods are making an assumption about the dataset they reference in any SOQL statement; especially if you are using testmethods at V23.0 or earlier or @isTest(seeAllData=true) annotation
When you run testmethods in sandbox, the SOQL calls will only fetch data known in Sandbox; but when you deploy, the same testmethods have available the full database in PROD to fetch from. Thus, the test execution contexts aren't in perfect fidelity
Best practice on testmethods is to only fetch sobjects that the testmethods create and no others