function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Dan Dodd 3Dan Dodd 3 

Import Case Data loader Trigger.caseTrigger: line 11

I am getting this error when I import the csv below. 
Where do I find Trigger.caseTrigger?
And/Or what are are the minimum fields to insert a record
 
caseTrigger: execution of BeforeInsert

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

Trigger.caseTrigger: line 11, column 1

Imported CSV:
"OWNERID","CREATEDDATE","DESCRIPTION","ORIGIN","PRIORITY","STATUS","SUBJECT"
"00G1U000002xbviUAA","2019-07-21","Seven Twenty","EMAIL","Medium","New","New subscription renewal order."

​​​​​​​





 
Best Answer chosen by Dan Dodd 3
VinayVinay (Salesforce Developers) 
Hi Dan,

Seems like you are missing few mandatory fields on insertion of Case object.

Try below code to execute in anonymous block in your org it will give you list of mandatory fields.

Schema.DescribeSObjectResult r = Case.sObjectType.getDescribe();
            Map<String,Schema.SObjectField> M = r.fields.getMap();
            for(String fieldName : M.keySet())
            { 
                Schema.SObjectField field = M.get(fieldName);
                Schema.DescribeFieldResult F = field.getDescribe();
              
              Boolean isFieldreq  = F.isNillable();
              System.debug('Required field' +fieldName);
            }    

Review below article regarding fields information on case.

https://help.salesforce.com/articleView?id=cases_fields.htm&type=5

Hope above information was helpful.

Please mark as Best Answer so that it can help others in the future.

Thanks,
Vinay Kumar

All Answers

VinayVinay (Salesforce Developers) 
Hi Dan,

Seems like you are missing few mandatory fields on insertion of Case object.

Try below code to execute in anonymous block in your org it will give you list of mandatory fields.

Schema.DescribeSObjectResult r = Case.sObjectType.getDescribe();
            Map<String,Schema.SObjectField> M = r.fields.getMap();
            for(String fieldName : M.keySet())
            { 
                Schema.SObjectField field = M.get(fieldName);
                Schema.DescribeFieldResult F = field.getDescribe();
              
              Boolean isFieldreq  = F.isNillable();
              System.debug('Required field' +fieldName);
            }    

Review below article regarding fields information on case.

https://help.salesforce.com/articleView?id=cases_fields.htm&type=5

Hope above information was helpful.

Please mark as Best Answer so that it can help others in the future.

Thanks,
Vinay Kumar
This was selected as the best answer
Dan Dodd 3Dan Dodd 3
Vinay, 
Thanks .. this helps a lot.
the results were a little confising until I tweaked the output.
Schema.DescribeSObjectResult r = Case.sObjectType.getDescribe();
Map<String,Schema.SObjectField> M = r.fields.getMap();
for(String fieldName : M.keySet())
{ 
    Schema.SObjectField field = M.get(fieldName);
    Schema.DescribeFieldResult F = field.getDescribe();
    
    Boolean isFieldnil  = F.isNillable();
    if (isFieldnil) {
        System.debug('Required field ' +fieldName );
    }  else {
        System.debug('Not Reqd field ' +fieldName );
    }
    
}    

 
VinayVinay (Salesforce Developers) 
Thanks Dan,

Good that it helped you.

Please mark as Best Answer if information was helpful so that it can help others in the future.

Thanks,
Vinay Kumar
Dan Dodd 3Dan Dodd 3
Vinay, 
This helped me find non-nillible fields but I still have the original issue :
caused by: System.NullPointerException: Attempt to de-reference a null object

Trigger.caseTrigger: line 11, column 1"
I'm using more fields now, all of those that were not nillible. 
"OWNERID","MASTERRECORDID","CONTACTID","SOURCEID","PARENTID","SUPPLIEDNAME","SUPPLIEDEMAIL","SUPPLIEDPHONE","SUPPLIEDCOMPANY","TYPE","STATUS","REASON","ORIGIN","LANGUAGE","SUBJECT","PRIORITY","DESCRIPTION","CLOSEDDATE","CONTACTPHONE","CONTACTMOBILE","CONTACTEMAIL","CONTACTFAX","COMMENTS"
"3D00G1U000002xbcb","","","","","dasdasdasd","ASDD@FDSs.IO","","","","New","","EMAIL","","New subscription renewal order.","HIGH","Seven TwentyOne Main bought a lot of stuff today","","","","ASDD@FDSs.IO","",""

But still get same error
 
VinayVinay (Salesforce Developers) 
Hi Dan,

Try to check line 11 in trigger and try to use null point check.

Eg:-

if (case.Sourcelement__c) == 'X0') 

Try to add null check.

if (case.Sourcelement__c) !=null')  &&  if (case.Sourcelement__c) == 'X0') 

Hope this will help you.

Thanks,
Vinay Kumar
Dan Dodd 3Dan Dodd 3
Where do I find Trigger.caseTrigger?
VinayVinay (Salesforce Developers) 
Hi Dan,

You should find under Object Manager--->Case--->Triggers.

You can deactivate trigger and insert records using dataloader if you do not want to make any changes to your logic.

Thanks,
Vinay Kumar
Dan Dodd 3Dan Dodd 3
 You have helped so much! thanks. I'll pick an answer 
VinayVinay (Salesforce Developers) 
It should work.

Please mark as Best Answer if information was helpful so that it can help others in the future.

Thanks,
Vinay Kumar
Dan Dodd 3Dan Dodd 3
It does work just wondering why I'm not getting the data I inserted, just the default fields. Sounds like a new issue!
 
VinayVinay (Salesforce Developers) 
Check the csv file and make sure you have values in fields and if you still see this new issue please log a case with salesforce support.

Thanks,
Vinay Kumar