0

The Below code is a test class where I get my null pointer exception
app Builder:

public with sharing class appmaker extends packmaker {
public override String buildpack(Object[] records) {
    PackController.Delete[] del = new PackController.Delete[]{};
        del = (PackController.Delete[])records;
    String packupper = '<table><tr><td>Sales #</td><td>Delete #</td><td> To</td><td>fro</td><td>upcoming</td><td>expected</td><td>Products</td></tr>';
    String packvalue = '';
    for(PackController.Delivery d: del) {
        packvalue += '<tr><td>'+packorder +'</td><td>'+d.contnumber +'</td><td>'+d.to+'</td><td>';
    }
    packvalue += '</table>';
    return packupper+packvalue;
}

}

1
  • Where are you populating the variable lstDeliveries used in getOutput method? – Santanu Halder Dec 9 '15 at 12:31
1

The error is thrown because del is Null at Line no 7 in ODCSVBuilder class

for(OpenDocumentsController.Delivery d: del)

Put a check at line 7 and update your code.

    if (del!=Null){
for(OpenDocumentsController.Delivery d: del) {
        CSVData += '<tr><td>'+d.RefSalesOrder +'</td><td>'+d.DeliveryNumber +'</td><td>'+d.ShipToParty +'</td><td>'+d.ShipToPartyName +'</td><td>'+d.DeliveryDateCSV +'</td><td>'+d.GIDateCSV +'</td><td>'+d.Product+'</td></tr>';
    }
}
3
  • Nope@salesforcesmarty..error occurs in test class – Priyalakshmi Dec 9 '15 at 13:15
  • Yes, but this is thrown by this class, as the variable was blank. Did you try after updating the code? – Salesforcesmarty Dec 9 '15 at 13:38
  • Yes yes..there was one more fault too..@salesforcesmarty..got it now. – Priyalakshmi Dec 9 '15 at 16:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.