You need to sign in to do that
Don't have an account?
garyb
ContentVersion trigger and future method
Hi all,
I have the following code:
trigger ContentVersion on ContentVersion (after insert) { HelperClass.doStuff(Trigger.newMap.keySet()); } public class HelperClass { @future public static void doStuff(Set<ID> recordIDs) { System.debug('recordIDs : + ' recordIDs); List<ContentVersion> content = [select ID from ContentVersion where ID in :recordIDs]; System.debug('content : ' + content); } }
A trigger that calls a future method, passes in the IDs of the record in the operation, and then retrieves those records from the database. Here's what happens:
The first debug statement shows that the recordIDs variable has a value
The second debug statement shows that the content is NOT retrieved - the list is empty.
Has anyone else seen this? Am I doing something wrong?
I this this may be a problem with the Content servlet. I adapted the above test for another object in our system and it behaves as expected.
I kind of fell into a temporary workaround. I have a validation rule on Content in my org. This validation rule seems to cause the trigger to fire again - why, I don't know, I wouldn't expect it to - and I put the call to the future method in the update trigger instead.
I'm going to raise a case about this.
EDIT: Case raised, case number 07591921
According to support, this is scheduled for a fix on 16th August. Yay!