• jeff.barnett
  • NEWBIE
  • 0 Points
  • Member since 2012
  • Kindred Healthcare

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 3
    Replies

 

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

 

 

 

 

 

 

Being new to APEX coding I’m struggling with how to determine the user’s profile in a trigger.  I know in VisualForce pages there is $Profile.  Is there something similar to that in triggers?

 

Thanks

Jeff

Is anyone else getting the following errors in the Progress tab in their DC sandboxes?
They show up before anything is opened, prior to that there was an error about Metadata failing to return the correct amount of lines. The prior error corrected itself after 10 days.

Getting all queued deployments for container=undefined
Creating deployment for containerId undefined Save=true runTests=false
Creating or Updating containerMember for containerId=undefined

 

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