Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [null-pointer]

The tag has no usage guidance, but it has a tag wiki.

1
vote
1answer
20 views

How to resolve Attempt to de-reference a null object in Apex Controller

I am trying to bind my map value to wrapper class in apex controller . I am getting System.NullPointerException: Attempt to de-reference a null object. I couldn't understand where I am going wrong. ...
2
votes
1answer
209 views

Is there any way to make an Apex method parameter lazy?

Let's say I want to call a method like: doSomething(a.b.c.d.e.f()); I know that this might be an expensive operation and a, a.b, a.b.c, a.b.c.d, and a.b.c.d.e might all be null, however I would ...
1
vote
3answers
64 views

Before Trigger System.NullPointerException: Attempt to de-reference a null object

I keep getting a null pointer exception error as follows : System.NullPointerException: Attempt to de-reference a null object Stack Trace: Class.ColloTest_utoStudentIDTrigger....
0
votes
0answers
15 views

Formula field in a Predefined Field Value (Email)

I have a record, namely Quote, which has a lookup relationship with Contact. Now, I'm creating an Email tab under the Activity, and I want the fields (To, From, Subject, etc..) to be auto-populated. ...
3
votes
1answer
170 views

Apex `if (Boolean) `. Null exception virtually renders this check useless and unsafe

Being that an if (booleanVariable) check, where booleanVariable is null, throws a NullPointerException, it would seem that this check is unsafe. If so why would Apex allow it? This is especially true ...
0
votes
1answer
27 views

bluewolf-beyond/selector attempt to de-reference a null object

Our org uses a mix of a variety of open source packages including bluewolf-beyond/selector This is a nifty package that allows construction of sobject list filters using a builder pattern that is ...
3
votes
4answers
404 views

|FATAL_ERROR|System.NullPointerException: Attempt to de-reference a null object on my Apex Trigger

I'm kind of new in Apex development and I'm writing a before insert, before update trigger to a custom object that is going to be upserted through an API integration. Is very basic code but I don't ...
-1
votes
1answer
41 views

Help Me Solve A Null Pointer

I am trying to refactor some code. Right now I have a trigger calling lots of methods. And I would like to to have it call on master method. Right now I am getting a null pointer exception. And I don'...
0
votes
1answer
38 views

Attempt to de-reference null object (Custom File Import)

The requirement is to import a tab separated text file and updated the records matching with some statuses then display success to for failure with the list of records. I wrote the following VF and ...
-2
votes
2answers
66 views

Null pointer Exception in Apex controller

I am getting "FATAL_ERROR|System.NullPointerException: Attempt to de-reference a null object" in Apex controller when i click on update link pop up. Its showing in query with " ulstAsset ".I am newbie ...
-1
votes
1answer
118 views

Test Class for Trigger Null Pointer Exception

I am new to apex. Getting this error System.DmlException: Upsert failed. First exception on row 0 with id aBfn000000062BMCAY; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, OP_DeferralTrigger: ...
0
votes
2answers
36 views

System.NullPointerException: Attempt to de-reference a null object Class.CollectionMaster.getCollectionMaster: line 9, column 1

@RestResource(urlMapping='/CollectionMaster/*') global with sharing class CollectionMaster{ @HttpPOST global static CollectionWrapper getCollectionMaster(String userName){ list<...
0
votes
1answer
24 views

Attempt To De-reference a Null Object on a Before Trigger [duplicate]

I am trying to a write what should be a pretty simple trigger to compare an old score with a new score and increment a variable based on the difference. The default field values are set to 0. I ...
0
votes
1answer
50 views

Null pointer exception when using {get; set;}

I'm trying to build a custom VF quick action on the Case object that allows users to update checkboxes for case fields and also lets them add some comments that will later be posted to chatter, but ...
0
votes
2answers
30 views

how to add all child in map as a list in trigger handler?

On Entity__c object on that have Event as a related list. i want when i change the owner of the Entity then Owner of the Event also get change. for this i write the trigger on after update.but from UI ...
0
votes
1answer
113 views

@future Attempt to de-reference null object

The business requirement is to have a lookup relation ship between a Contract and Opportunity. A field on the opportunity must get the SUM of a custom field on the Contracts which belong to the ...
0
votes
1answer
132 views

System.NullPointerException: Attempt to de-reference a null object: () and Querying account hierarchy

I am currently developing the code that will update al the children accounts related to this parent account if this parent account gets 's updated.  gets updated.  I have two questions: What could ...
1
vote
0answers
72 views

How can the Describe for a Field of getPopulatedFieldsAsMap() be null

I'm doing a CRUD check on Field level, since under some weird circumstances our customers don't have update rights on Record level, but only on fields (it's a guest license). So in addition to the ...
0
votes
2answers
31 views

System.NullPointerException: Attempt to de-reference a null object(about feeditem object)

I'm trying to add an action on Visualforce Page which enable end users to post messages on a case. But when I click the button, I get an error like: System.NullPointerException: Attempt to de-...
1
vote
1answer
190 views

NullPointerException: Attempt to de-reference a null object in a batchclass

I have this batchclass with which I want to update some checkboxes on account with the values of related assets checkbox values. When running the class I get an System.NullPointerException: Attempt to ...
0
votes
1answer
51 views

Issue with mapping the fields when there is an apex webservice xml response (Revised with new errors)

Apex call out has an xml response.How can I map the fields in Salesforce to the response I receieved. I could map the fields like clean etc. But how could I map fields like make,model, year relatively....
0
votes
1answer
108 views

Error updating custom Salesforce object using Talend ETL - Status Code: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY

I am trying to update the name of one of the Salesforce Custom Objects, and using Talend Data Integration tool for the same. The action on the salesforce Object is 'Update' and I only have two columns ...
-4
votes
1answer
120 views

Why do I get a NullPointerException?

The below code throws a NullPointerException at this line: WClass W = new WClass(con); WC.add(W); Here is the complete code: public class WrapperClassExample{ public List<WClass> WC{get;set;...
1
vote
2answers
51 views

Apex class in trigger populates lookup based on string input

I am writing a trigger on my Case object to run (before insert). I am receiving the following error: System.DmlException: Insert failed. First exception on row 0; first error: ...
0
votes
1answer
24 views

Null pointer exception on bulk update but working when I update manually via UI

I'm running a batch update on tasks and my task trigger handler is throwing a null pointer exception error. If I go through and update the tasks individually, I don't have any issues with them. If I ...
-3
votes
2answers
47 views

Null Pointer Exception on line 15,18 and 22 [closed]

trigger RollUpSummaryTrigger on Contact(after insert) { Set < id > accIdList = new Set < id > (); for (Contact con: Trigger.new) { accIdList.add(con.accountid); } List < account ...
0
votes
1answer
38 views

Getting this error after running my test class “System.NullPointerException: Attempt to de-reference a null object”

I'm currently modifying a test class made by someone because its getting this error. The part at which the error shows up is at the If condition. I'm not sure why it gives that error at that part ...
0
votes
1answer
154 views
1
vote
1answer
71 views

Unexpected null reference - how can this happen?

I have code in a task trigger handler that looks to see if the whoid is a contact, and if so, set a pointer in the Task object to a field in the contact. So the trigger does this: - loop through the ...
0
votes
1answer
97 views

Test class throwing argument cannot be null error

I am seeing System.NullPointerException: Argument cannot be null in my test class Below is the controller method that i am trying to cover : public void Synchsongmethod() { system.debug(...
3
votes
2answers
805 views

In this code, where is the attempt to de-reference a null object?

I've got some simple code and I'm wondering if someone can help me understand why it would result in the "Attempt to de-reference a null object" error? This is part of a custom controller that I'm ...
0
votes
1answer
245 views

System.NullPointerException: Attempt to de-reference a null object JSON2Apex

Having an issue parsing my json using Apex when the value is null. My Json2Apex is being returned like so. [object1=cls_object:[amount=11000, amount_refunded=0, application=null, application_fee=...
1
vote
1answer
356 views

Try/Catch for Attempt to Dereference Null Object

Is there a way I can test with an IF statement for a null object. Using an IF (obj==null) throws the error. How can I account for these? With SOQL, I use a list and check the number. However, the ...
2
votes
1answer
49 views

Null Pointer if sObjectType isn't Case

I have the apex trigger below that is meant to check the WhatId on a new Task if the WhatId belongs to a case. The trigger then populates fields on the related Case for ActivityDate and Task Type. ...
0
votes
1answer
308 views

Test Class Error Message [closed]

I have a test class for a custom Visualforce page controller and I am getting the following error message: Error Message System.NullPointerException: Attempt to de-reference a null object Stack ...
2
votes
1answer
344 views

Issue with Invocable Method to Call Queueable

Ok, I'm officially confused. I've written some code to attempt to populate a Campaign lookup field on Opportunity based on some logic. The basic flow is Process Builder (so the client can ...
1
vote
1answer
107 views

Attempt to dereference null object error because emailTextBody is in fact null

I have an email service with Apex that drives a class reservations system that reads in a keyword from and email body and will update a record if the sender is coming or not. I will get an "Attempt ...
1
vote
1answer
28 views

Error when updating a custom field in a custom object - Attempt to de-reference a null object Error

I am trying to update a field in a custom object and I have stripped back my code to the bare minimum. I am getting this error on submission when I click the save button. How do I fix it? System....
0
votes
2answers
25 views

Map not getting populated

I have below code where the Map is not getting populated and throws Null Pointer error. System.NullPointerException: Attempt to de-reference a null object Code: for(Business_Plan_abv__c obj : [...
0
votes
1answer
44 views

Apex Trigger lookup that contains 'xyz' - NullPointerException

first post so apologies if there's some issues. I'm looking to build an Apex trigger that looks up an Account name that contains "DUNNES" in the title (among other rules), and execute an email class. ...
3
votes
4answers
715 views

Test method fails with “Attempt to de-reference a null object” Trying to use 2 record types of contact

In a test class, I need to have 2 contacts with different record types. Contact Record Types: Client_Only and Candidate. Account Contact is Client only, and Applicant is Candidate. Line 8 is ...
0
votes
2answers
954 views

Test class for a controller - Unable to set the variable in the constructor

I have a controller: public class XYZcontroller{ public object__c sr{get;set;} public String srid; public XYZcontroller(ApexPages.StandardController controller) { sr = (object__c) ...
2
votes
1answer
577 views

System.NullPointerException when using .contains in a for loop

I am iterating through an array of a List of Maps and want to run an if function whenever an item from the list meets a condition. The problem I am currently facing is Salesforce producing the ...
2
votes
1answer
30 views

Help with my Trigger Logic

In the Below code I want to assign Case to WhatId in my Task record when a case with the same contact as Opportunity is created. I am getting a System.NullPointerException at tsk.WhatId = cas1.Id when ...
0
votes
1answer
137 views

NullPointerException while parsing XML callout response

I am getting attempt to de-reference null object error the below callouts. Class 1: public class ProcessImgCallout { @future (callout=true) public static void SendImage(ID id) { ...
1
vote
1answer
126 views

failed to parse the XML file in apex- gives null pointer exception error

I'm trying to parse the below XML file: <articles> <article> <source>EN-US</source> <target>SL</target> <id>ka1800000000eCYAAY<...
0
votes
2answers
307 views

Null pointer exception to fetch custom settings data

I have below code where I face null pointer exception when the custom settings data is not populated. I simply need to ignore if it's null rather than getting an exception in this trigger code. Can ...
3
votes
1answer
389 views

attempt to de-reference null object in test class

I'm attempting to write a test method for my constructor and when I get to a method in my non-test class where I'm assigning a value to the object passed I get a "attempt to de-reference null object ...
1
vote
1answer
501 views

Test Method throwing null pointer exception on custom setting

I am trying to write a test class. My Apex class has the following constructor: public NController(ApexPages.StandardController controller) { cas = (Case) controller.getRecord(); csId = ...
0
votes
1answer
38 views

Custom Controller help

I am trying to display Picklist values based on the picklist field selected on a VF page, I get Null pointer exception . Can someone please help.