7

I want to do a bulk update of records in parallel, but Batch Apex doesn't permit this.

I was wondering if the following solution would work:

  1. I have an SObject defined that holds a value for the query, limit & offset values.
  2. I split a job up according to a max say 1000 records and the correct offset and I add these values one at a time to the above table, which fires a trigger that calls an @future method.
  3. The @future method does all the processing.

Now the question I have is -

  1. Does the above scenario violate the @future invocation limit of 10 from the calling code? i.e. Does the trigger callout count towards the limit in the apex calling the insert record.

thanks

2
  • 3
    I would highly recommend watching youtube.com/watch?v=ZqqiIg_mynY&feature=youtu.be - Design Patterns for Async Apex (Dreamforce 13) for an industrial strength solution that has no limits. Done by the incomparable Dan Appleman
    – cropredy
    Jun 20, 2014 at 1:05
  • Why batch can not be used in your scenario? For the limit, I think yes, you can check the limit in your debug log in developer console.
    – Jair
    Jun 20, 2014 at 1:49

1 Answer 1

2

Well first let me clarify if i understand your idea right:

  1. You have custom object object
  2. On the insert of that object you have trigger
  3. in that trigger you have future call
  4. In Future call you are again inserting object(point 1) which in theory run recursively.

No, This will not work!

Why?

You can not call future method from another feature method in your case you are calling trigger and that is calling future method.

It will fail at second iteration as it will realize that you are calling future from future.

You cannot call a method annotated with future from a method that also has the future annotation. Nor can you call a trigger from an annotated method that calls another annotated method.

Best option is follow the advise given by cropredy in comment

1
  • 1
    Hey Atul, not sure if you're aware but you can get standard <ol> formatting by using 1. instead of 1).
    – Adrian Larson
    Aug 22, 2016 at 13:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .