I have a trigger on the user object which calls an external web service to assign some values to every newly inserted user but now client want to insert the user's via batch(which we don't have access to) so I want to know if we can call web service without future or any way to solve this problem.


You can use a callout in batch Apex, to do that you must specify Database.AllowsCallouts in the class definition as explained in this link.

For example the syntax will be:

global class SearchAndReplace implements Database.Batchable<sObject>, 
              //Business logic you want by implementing Batchable interface methods

Also, you can refer to this link for implementation.

| improve this answer | |
  • The problem here is we don't have access to batch that inserts user's as it is handled by client – Ishan May 2 '17 at 9:00
  • 1
    You can write a utility class which handles the call out and ask the client to implement the interface and invokes your utility class method to perform the action. – Saroj Bera May 2 '17 at 9:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.