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
jeff.barnettjeff.barnett 

Getting "Validation Errors While Saving Record(s)" when calling Test.loadData()

 

I just finished creating a VF page and associated controller and ready now to test.  The SOQL in the controller has a where clause filtering on users who have not logged into SFDC in the last 90 days.  So my plan was to use Test.loadData to set the LastloginDate value. The CSV is listed below. After it's loaded in as a static resource and I ran the test method listed below but get an error message - "Validation Errors While Saving Record(s)". The debug log has a line "FATAL_ERROR|Internal Salesforce.com Error" but nothing more.  I read a post talking about null/empty date fields so I removed the Last login Date column and tried again but still got the same error.  Thinking it might be an issue with the UserRoleID and ProfileID values I removed them and run again - still nothing.  I even diabled all validation rules on the User object but no luck. Can I not load users this way?  If I can't use Test.loadData() is it possible to set LastLoginDate via DML?

 

 

User File

UsernameFirstNameLastNameEmailAliasCommunityNicknameIsActiveTimeZoneSidKeyUserRoleIdLocaleSidKeyEmailEncodingKeyProfileIdUserTypeLanguageLocaleKeyLastLoginDate
ts@a.comTSts@a.comSS0America/Los_Angeles000000000000000AAAen_USISO-8859-100e300000019GVoAAMStandarden_US3/15/2010 19:26
sd@c.comSDsd@c.comDD1America/Chicago00E300000019HPcEAMen_USISO-8859-100e300000019GVoAAMStandarden_US1/2/2013 18:16
jk@d.comJKjk@d.comKK0America/Chicago000000000000000AAAen_USISO-8859-100e300000019GVoAAMStandarden_US4/7/2011 13:52

 

Test Method

@isTest
private class DeactivateUserControllerTest {

    static testMethod void testLoadData() {
    	
        List<sObject> ls = Test.loadData(User.sObjectType, 'testUserAccounts');
        System.debug('\n\n******************************\nList Size: ' + ls.size());
    }
}

Debug Log

Debug Log:

26.0 APEX_CODE,FINEST;APEX_PROFILING,INFO;CALLOUT,INFO;DB,INFO;VALIDATION,INFO;WORKFLOW,FINEST
14:28:53.431 (1431535000)|EXECUTION_STARTED
14:28:53.431 (1431567000)|CODE_UNIT_STARTED|[EXTERNAL]|01pe00000008YMR|DeactivateUserControllerTest.testLoadData
14:28:53.432 (1432403000)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:5
14:28:53.432 (1432431000)|METHOD_ENTRY|[23]|01pe00000008YMR|DeactivateUserControllerTest.DeactivateUserControllerTest()
14:28:53.432 (1432437000)|STATEMENT_EXECUTE|[23]
14:28:53.432 (1432625000)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:5
14:28:53.432 (1432638000)|STATEMENT_EXECUTE|[23]
14:28:53.432 (1432650000)|METHOD_EXIT|[23]|DeactivateUserControllerTest
14:28:53.432 (1432695000)|HEAP_ALLOCATE|[29]|Bytes:5
14:28:53.432 (1432702000)|STATEMENT_EXECUTE|[25]
14:28:53.432 (1432706000)|STATEMENT_EXECUTE|[29]
14:28:53.432 (1432716000)|HEAP_ALLOCATE|[29]|Bytes:4
14:28:53.432 (1432771000)|HEAP_ALLOCATE|[29]|Bytes:16
14:28:53.473 (1473691000)|FATAL_ERROR|Internal Salesforce.com Error
14:28:52.844 (1473720000)|CUMULATIVE_LIMIT_USAGE
14:28:52.844|LIMIT_USAGE_FOR_NS|(default)|
  Number of SOQL queries: 0 out of 100
  Number of query rows: 0 out of 50000
  Number of SOSL queries: 0 out of 20
  Number of DML statements: 0 out of 150
  Number of DML rows: 0 out of 10000
  Number of script statements: 1 out of 200000
  Maximum heap size: 0 out of 6000000
  Number of callouts: 0 out of 10
  Number of Email Invocations: 0 out of 10
  Number of fields describes: 0 out of 100
  Number of record type describes: 0 out of 100
  Number of child relationships describes: 0 out of 100
  Number of picklist describes: 0 out of 100
  Number of future calls: 0 out of 10

14:28:52.844|CUMULATIVE_LIMIT_USAGE_END

14:28:53.473 (1473754000)|CODE_UNIT_FINISHED|DeactivateUserControllerTest.testLoadData
14:28:53.473 (1473764000)|EXECUTION_FINISHED

 

 

 

 

 

kevindotcarkevindotcar

Hi


That roleid (000000000000000AAA) looks mighty fishy... there is no recordtype with a "000" prefix tha I know of....

 

jeff.barnettjeff.barnett

The roleid (000000000000000AAA) is what SalesForce provided via the Data Export mechanism.  It's SalesForce's value for nothing.  I blanked out those values but no luck.  I've gotten to the point where I removed all columns.  SalesForce kindly responds with a message stating that I need to provide required fields. Those required fields are: Username, Email, LastName, Alias, CommunityNickname, and ProfileId. I set the ProfileID to '00e300000014yOHAAY' which equals "Standard Platform User".  But the system throws an unexpectedException error on the Test.LoadData method.

 

16:35:23.469 (1469368000)|FATAL_ERROR|System.UnexpectedException: Salesforce System Error: 784454995-12967 (954434998) (954434998)

 

(System Code)

Class.DeactivateUserControllerTest.testLoadData&colon; line 28, column 1

 

 

jeff.barnettjeff.barnett
The data came from running a data export job on the User object. "000000000000000AAA" is what populated in the user records where the role field was blank. I've even tried deleting those values (leaving it blank), changing it to another UserRoleId value, and removing the column completely but each attempt fails. The information contained in this E-mail transmission is intended only for the use of the individual or entity to whom it is addressed. It may contain privileged, confidential, and protected health information. If you received it in error, you are on notice of its status. Please notify us immediately by reply e-mail and then please delete this message from your system. Please do not copy it or use it for any purposes, or disclose its contents to any other person. To do so could violate state and Federal privacy laws. Thank you for your cooperation. Please contact the sender if you need assistance. Dedicated to Hope, Healing and Recovery.