You need to sign in to do that
Don't have an account?
isArchived Event/Task Field
Hi all,
I have a scenario where I need to create test coverage for some code that deals with Archived Activities (Events and Tasks with isArchived = TRUE).
1) Aside from setting SeeAllData = TRUE, is there any way to create a few Archived records?
2) I tried updating my Activities per the criteria here: http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_guidelines_archive.htm, but it doesn't set isArchived to true for me. I'm assuming this is some sort of nightly job? If so, is there a system method that I can use to trigger this? On the flip side, in a non-testing environment, if I update an Event or Task to violate the Archive criteria, isArchived is instantly updated to false.
Thanks in advance!
2) It's not necessarily "nightly" (it's always day somewhere in the world), but it does run only infrequently, perhaps every 30 or 60 minutes, and definitely not anything you can control (at least, you can't set it to "true").
If you want your code coverage that badly, you'll have to work for it. I'd suggest using a static variable, and use that to simulate a query:
Event[] records = [SELECT ... ];
if( Util.pretendArchive )
records = Util.makeFakeEvents();
for(event record:records) {
...
}
Using this design, you can have mock records to use. I'd say you could try Test.loadData, but I don't think it'll allow bypassing audit fields, etc.
All Answers
2) It's not necessarily "nightly" (it's always day somewhere in the world), but it does run only infrequently, perhaps every 30 or 60 minutes, and definitely not anything you can control (at least, you can't set it to "true").
If you want your code coverage that badly, you'll have to work for it. I'd suggest using a static variable, and use that to simulate a query:
Event[] records = [SELECT ... ];
if( Util.pretendArchive )
records = Util.makeFakeEvents();
for(event record:records) {
...
}
Using this design, you can have mock records to use. I'd say you could try Test.loadData, but I don't think it'll allow bypassing audit fields, etc.
Thanks sfdcfox.
If anyone else has input on the infrequent nature of the updating of the isArchived field, please share.
EDIT: Or if you have any ideas as to how to consistently generate isArchived Activities in a Dev org, I'd love to know. I didn't see the archive bit flip for 24+ hours (checked at 24 hours later, no luck, then checked about 3 days later - bingo).