We’re rewarding the question askers & reputations are being recalculated! Read more.
9 Updated due to Known Issue change
source | link

I've raised support case 13752643 for the problem with Test.setCreatedDate not working with a Note that was created in the test method transaction. I'll relay the important updates from the case here.

See Known Issue Test.setCreatedDate() does not work for Note object

Update: 17th October - The known issue is now marked as "Fixed - Winter '17"


Repo code against v36.0 on na5.

@IsTest
public class Test_SettingCreatedDateOnNote {

    @isTest
    public static void CleanUp_Test() {
        Account testAccount = new Account();

        testAccount.Name = 'Test Account';

        insert testAccount;

        System.assertNotEquals(null, testAccount.Id);

        Note testNote = new Note();

        testNote.Title = 'Test Account Note';
        testNote.Body = 'Test Account Note Body.';
        testNote.ParentId = testAccount.Id;

        insert testNote;

        System.assertNotEquals(null, testNote.Id);

        Test.setCreatedDate(testAccount.Id, DateTime.now().addMonths(-6));
        Test.setCreatedDate(testNote.Id, DateTime.now().addMonths(-6));

        Test.startTest();

        System.assert([SELECT COUNT() FROM Note] > 0);

        Test.stopTest();
    }

}

The line Test.setCreatedDate(testNote.Id, DateTime.now().addMonths(-6)); throws the following exception:

System.NoDataFoundException: The sObject with the ID 0027000000VBxllAAD isn’t part of this transaction. Provide the ID of an sObject that this test method created.

I've raised support case 13752643 for the problem with Test.setCreatedDate not working with a Note that was created in the test method transaction. I'll relay the important updates from the case here.

See Known Issue Test.setCreatedDate() does not work for Note object


Repo code against v36.0 on na5.

@IsTest
public class Test_SettingCreatedDateOnNote {

    @isTest
    public static void CleanUp_Test() {
        Account testAccount = new Account();

        testAccount.Name = 'Test Account';

        insert testAccount;

        System.assertNotEquals(null, testAccount.Id);

        Note testNote = new Note();

        testNote.Title = 'Test Account Note';
        testNote.Body = 'Test Account Note Body.';
        testNote.ParentId = testAccount.Id;

        insert testNote;

        System.assertNotEquals(null, testNote.Id);

        Test.setCreatedDate(testAccount.Id, DateTime.now().addMonths(-6));
        Test.setCreatedDate(testNote.Id, DateTime.now().addMonths(-6));

        Test.startTest();

        System.assert([SELECT COUNT() FROM Note] > 0);

        Test.stopTest();
    }

}

The line Test.setCreatedDate(testNote.Id, DateTime.now().addMonths(-6)); throws the following exception:

System.NoDataFoundException: The sObject with the ID 0027000000VBxllAAD isn’t part of this transaction. Provide the ID of an sObject that this test method created.

I've raised support case 13752643 for the problem with Test.setCreatedDate not working with a Note that was created in the test method transaction. I'll relay the important updates from the case here.

See Known Issue Test.setCreatedDate() does not work for Note object

Update: 17th October - The known issue is now marked as "Fixed - Winter '17"


Repo code against v36.0 on na5.

@IsTest
public class Test_SettingCreatedDateOnNote {

    @isTest
    public static void CleanUp_Test() {
        Account testAccount = new Account();

        testAccount.Name = 'Test Account';

        insert testAccount;

        System.assertNotEquals(null, testAccount.Id);

        Note testNote = new Note();

        testNote.Title = 'Test Account Note';
        testNote.Body = 'Test Account Note Body.';
        testNote.ParentId = testAccount.Id;

        insert testNote;

        System.assertNotEquals(null, testNote.Id);

        Test.setCreatedDate(testAccount.Id, DateTime.now().addMonths(-6));
        Test.setCreatedDate(testNote.Id, DateTime.now().addMonths(-6));

        Test.startTest();

        System.assert([SELECT COUNT() FROM Note] > 0);

        Test.stopTest();
    }

}

The line Test.setCreatedDate(testNote.Id, DateTime.now().addMonths(-6)); throws the following exception:

System.NoDataFoundException: The sObject with the ID 0027000000VBxllAAD isn’t part of this transaction. Provide the ID of an sObject that this test method created.

8 Linked to new known issue
source | link

Update from support 04/27/2016 01:22:47 PM PDT

I was able to replicate the issue in my local org. I am reaching out to my internal team on this and will escalate to R&D as needed. I will update you on the status again tomorrow between 11 and 12 PM Pacific time.

Update from support 04/28/2016 03:48:02 PM PDT

I have reached out to the internal team about the issue describing the details. We are currently undergoing a discussion about the issue. As of now I don't anything concrete yet. I will keep you posted on the status, with my next update between 2 and 3 PM Pacific time tomorrow.

Update from support 04/29/2016 03:56:18 PM PDT

Our R&D team is investigating the issue and and observed some locking issue on the Note object to be causing the problem. I will have more details on this on Monday. I shall keep you posted on the issue with my next update on Monday between 2 and 3 PM Pacific time.

Update from support 05/02/2016 04:42:16 PM PDT

We are logging an investigation on the issue for the R&D to determine if this is a bug. The team is looking into the issue. I will keep you updated on the status with my next update between 4 and 5 PM Pacific time tomorrow.

Update from support 05/05/2016 03:18:43 PM PDT

The R&D team has logged a Bug for the issue, however the ETA has not been decided yet. As of now there were no workarounds suggested. Could you let me know if the workarounds discussed in the stackexchange (JSON.deserialize or Util class) worked for your scenarios.

Update from support 05/11/2016 15:42:08See Known Issue Test.setCreatedDate() does not work for Note object

The R&D team has logged a Bug for the issue, however the ETA has not been decided yet. As of now the ETA for patch release not yet been decided.

Update from support 04/27/2016 01:22:47 PM PDT

I was able to replicate the issue in my local org. I am reaching out to my internal team on this and will escalate to R&D as needed. I will update you on the status again tomorrow between 11 and 12 PM Pacific time.

Update from support 04/28/2016 03:48:02 PM PDT

I have reached out to the internal team about the issue describing the details. We are currently undergoing a discussion about the issue. As of now I don't anything concrete yet. I will keep you posted on the status, with my next update between 2 and 3 PM Pacific time tomorrow.

Update from support 04/29/2016 03:56:18 PM PDT

Our R&D team is investigating the issue and and observed some locking issue on the Note object to be causing the problem. I will have more details on this on Monday. I shall keep you posted on the issue with my next update on Monday between 2 and 3 PM Pacific time.

Update from support 05/02/2016 04:42:16 PM PDT

We are logging an investigation on the issue for the R&D to determine if this is a bug. The team is looking into the issue. I will keep you updated on the status with my next update between 4 and 5 PM Pacific time tomorrow.

Update from support 05/05/2016 03:18:43 PM PDT

The R&D team has logged a Bug for the issue, however the ETA has not been decided yet. As of now there were no workarounds suggested. Could you let me know if the workarounds discussed in the stackexchange (JSON.deserialize or Util class) worked for your scenarios.

Update from support 05/11/2016 15:42:08

The R&D team has logged a Bug for the issue, however the ETA has not been decided yet. As of now the ETA for patch release not yet been decided.

See Known Issue Test.setCreatedDate() does not work for Note object

7 added 197 characters in body
source | link

Update from support 05/11/2016 15:42:08

The R&D team has logged a Bug for the issue, however the ETA has not been decided yet. As of now the ETA for patch release not yet been decided.

Update from support 05/11/2016 15:42:08

The R&D team has logged a Bug for the issue, however the ETA has not been decided yet. As of now the ETA for patch release not yet been decided.

6 added 321 characters in body
source | link
5 Next update from support.
source | link
    Bounty Ended with 50 reputation awarded by battery.cord
4 added 321 characters in body
source | link
3 Daily Update from support
source | link
2 Update from support
source | link
1
source | link