You need to sign in to do that
Don't have an account?
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
Username | FirstName | LastName | Alias | CommunityNickname | IsActive | TimeZoneSidKey | UserRoleId | LocaleSidKey | EmailEncodingKey | ProfileId | UserType | LanguageLocaleKey | LastLoginDate | |
ts@a.com | T | S | ts@a.com | S | S | 0 | America/Los_Angeles | 000000000000000AAA | en_US | ISO-8859-1 | 00e300000019GVoAAM | Standard | en_US | 3/15/2010 19:26 |
sd@c.com | S | D | sd@c.com | D | D | 1 | America/Chicago | 00E300000019HPcEAM | en_US | ISO-8859-1 | 00e300000019GVoAAM | Standard | en_US | 1/2/2013 18:16 |
jk@d.com | J | K | jk@d.com | K | K | 0 | America/Chicago | 000000000000000AAA | en_US | ISO-8859-1 | 00e300000019GVoAAM | Standard | en_US | 4/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
Hi
That roleid (000000000000000AAA) looks mighty fishy... there is no recordtype with a "000" prefix tha I know of....
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: line 28, column 1