1

We are encountering a problem with callouts:

Two salesforce instances. SFDC A instance having a future callout method calling a REST API class in SFDC B instance. SFDC B instance updating case locally triggering an execution of after update. After update triggers makes a future callout to our ERP( not salesforce) Without waiting for a response from ERP, SFDC B instance returns the Case Number to SFDC A instance. Salesforce forums say that we cannot make a callout to another SFDC instance from REST API class, but here i am making a callout to ERP and only returning a response to the original REST request . Please help me in understanding the documentation. I am little confused.

Please respond. Its urgent for our go Live.

  • There is a related topic : salesforce.stackexchange.com/questions/6142/… – ckarimanoor Jan 12 '16 at 15:28
  • You need to post your code and include any other relevant details. – Davin Casey Jan 12 '16 at 15:29
  • basic idea is simple-- you can not do a callout during rest request or webservice request in salesforce. Exactly what is answered in question referenced by you – kurunve Jan 12 '16 at 15:33
  • @karunve, i read in forums that we cannot make a callout to another SFDC instance. From your statement, we cannot make any callout from REST Api class. I will have to check REST API class documentation. Thanks for the input though. – ckarimanoor Jan 12 '16 at 15:35
  • @karunve i am not able to find any documentation specifically saying that we cannot make a Callout from REST Class. If your statement indeed turns out to be true, i will have to find other ways to implement my use case – ckarimanoor Jan 12 '16 at 16:15
0

I am not sure 100% of the root cause of your problem but you do have a few more things to try.

1) If you do not want/need a response from the called server you can create an "Outbound Message" from a Workflow Rule. This method will indeed make a callout for you, but will not capture a response

2) You can try calling an @future method or scheduling something for the future as a one-off. I have not personally tried these methods, so buyer beware, but kicking of any kind of asynchronous call should enable you to change the context and callout from it.

| improve this answer | |
  • Hi Sebastian, The ERP callout i am talking about is indeed a @future method. That is what is not being allowed and i am getting 'Callout Loop Not Allowed' error. – ckarimanoor Jan 12 '16 at 16:20
  • How about the "Outbound Message"? Would that work? Or a Queuable? – Sebastian Kessel Jan 12 '16 at 16:21
  • This link might help understand: developer.salesforce.com/forums/?id=906F00000009ABRIA2 – Sebastian Kessel Jan 12 '16 at 16:23
  • Unfortunately, not. We need a SR number from ERP Callout also. :) But that is not needed to be sent to original REST request.. I need a way to decouple these two transactions and automate them without user involvement and without using BATCH processes 1) Call out from SFDC A to SFDC B instance - REST CAll 2) SFDC B to ERP Callout - Apex callout. – ckarimanoor Jan 12 '16 at 16:23
  • I would use a Queueable, then. Or create a class with the "Schedulable" interface and put one in the queue 5 minutes into the future. Both of those come with limitations, so read up on them before implementing – Sebastian Kessel Jan 12 '16 at 16:25

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.