You need to sign in to do that
Don't have an account?
Sennah
Update operation works in test method, not in DataLoader
Hey all,
I am encountering a strange problem here: When I do a mass-update via my test class everything works fine. But when I load a file with the DataLoader in update mode it throws this error:
System.NullPointerException: Attempt to de-reference a null object
Here's a code snippet of which seems to make trouble. Line 3 is supposed to be the evil one.
for (Task t : trigger.new) {
body = t.Description;
bodyLength = body.length();
}
Any ideas?
Cheers,
Hannes
Thanks again guys... And here is the "solution":
I checked
but it has to be
... Thanks again for your input.
All Answers
Is the variable, bodyLength, initialized? You can use debug statements to check which one of those variables is null.
I wonder if the task description is null, if body gets set to null, and therefore body.length() throws the exception?
aalbert,
thank you for your input.
Yes, they are initialized.
Also, I am only processing those records which have a description.
Any body.length() would then be 0, wouldn't it?
... any more ideas out there?
Well, if the error is being thrown in those 3 lines of code, why not add logic that checks each field or variable if it is null. It sounds like this code executes in a trigger so why not use the addError() method or at least system.debug() to output an error message when one of those variables is null (t.description, body.length(), bodyLength).
If there's no description the body variable will be null, and so the call to body.length() will cause a null pointer exception.
Thanks again guys... And here is the "solution":
I checked
but it has to be
... Thanks again for your input.