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
Andrei MarkautsouAndrei Markautsou 

Internal Salesforce Error 318931575-52897 (-131831505) (-131831505)

Since Winter 18 update I'm getting the Internal Salesforce Error (-131831505) while executing Unit tests. Seems error persists during tests only. It works okay in real-time. I was able to find out that code fails on Inserting the task with custom Record Type Id which is part of the package:

Task task = new Task(Subject = "Subject",
                                 Description = "Description",
                                 ActivityDate = Date.today(),
                                 RecordTypeId = recordTypeId,
                                 Status = 'Completed'
                                 );
Tad Aalgaard 3Tad Aalgaard 3
We will need more information/code in order to help you on this as the problem is more than likely the result of a permission error 
Try the following 
@isTest(SeeAllData = true)
disable triggers on the Task object or any other objects that this test affects
disable Process Builder processes on this object or any other objects that this test affects

If I create and test the following it works for me without error.  My recordTypeId value will of course be different than yours.
 
@isTest
public class tastTest{
    
	@isTest
	static void firstTest() {
    
    Id recordTypeId =  '0121D0000008Tlq';
	Task task = new Task(Subject ='Subject',
                                 Description = 'Description',
                                 ActivityDate = Date.today(),
                                 RecordTypeId = recordTypeId,
                                 Status = 'Completed'

                        );
        
    }
}



 
Andrei MarkautsouAndrei Markautsou
Hi Tad,

Thank you for looking into this. Your reply helped to understand that the issue caused by different code. Please see below the test method which throws the error (Internal Salesforce Error: 639561078-67796 (-131831505) (-131831505)):
 
static testMethod void testTaskCreation() {
        	
        	Id recordTypeId = Schema.SObjectType.Task.getRecordTypeInfosByName().get('CustomRecordType').getRecordTypeId();
        	
        	Task task = new Task(Subject = 'TestSubject',
								 Description = 'TestDescription',
	                             ActivityDate = Date.today(),
	                             RecordTypeId = recordTypeId
	                             );
        	
        	System.Debug('TaskWhoIds :: ' + task.TaskWhoIds);
    	
    		if (task.TaskWhoIds != null) {
    			for (String id : task.TaskWhoIds) {
    				System.Debug('TaskWhoId :: ' + id); // Throws Error
    			}      	
    		}                 
        }
I still think this is happening during Unit test only. Anyway this is not critical, I just removed the Debug logging.

Thanks,
Andrei
       

 
Tad Aalgaard 3Tad Aalgaard 3
Change
 if (task.TaskWhoIds != null) {
to 
 
 if (task.TaskWhoIds.size()!=0) {