The Stack Overflow podcast is back! Listen to an interview with our new CEO.

New answers tagged

1

One what to do this is with continuations. It's a callback mechanism that is built into Visualforce. See Make Long-Running Callouts from a Visualforce Page. You can also use them from Lightning - Invoking Apex Continuations from Lightning Components. Or a more official version from Summer '19 - Make Long-Running Callouts with Continuations.


3

It should be as simple as using a Queueable with Database.AllowsCallouts instead of using a future method. See the product documentation for details. There are lots of alternatives you could consider in terms of the over-all approach, such as generating platform events with the JSON (as text) in them, but this approach does keep it clean and simple.


0

The solution to this (and best practice for all invocable apex that does callouts is to do the callout in either an @future or Queueable). This way The DML done by the flow (or subflow) + invocable invocation occurs in transaction 1 The callout is done in transaction 2


1

Turns out that the doCloseModal() function was closing the modal before the doDisplayToastMsg() function inside the fetch() was getting a chance to run. The doDisplayToastMsg() after the fetch() was displaying the toast correctly because it ran before the fetch() completed. Solution was to move the doCloseModal() to inside the fetch(), after the ...


2

added You get error message ONLY when this is undefined - not when this is re-scoped to different object. For your toast to work correctly this should refer to class HoldModal as toast should be invoked on instance of the class and not on any other element. Although you are trying to save the scope of this by using const thisReference = this;, the scope of ...


0

You have to many then().then() promises, this scope has changed a lot. Then when you call this.dispatchEvent(toastEvt); , this does not point to the component. A quick thing I can think of is to provide component reference in doDisplayToastMsg doDisplayToastMsg(variant, title, message , componentThis) { const toastEvt = new ShowToastEvent({ ...


0

It turns out to be zero because (a) the future method is not called until Test.stopTest(), and (b) immediately after Test.stopTest(), you go back in to the test's governor limits. In addition to Adrian's suggestion, you could also have a "universal" method that does the actual callout and provides a nice hook for consistent monitoring: public class ...


6

Typically, if I want to verify the callout is made and there may be asynchronous processing involve, I just track it on my mock. class MyMock implements HttpCalloutMock { Integer calls = 0; public HttpResponse respond(HttpRequest request) { calls++; // mock implementation here } } Then, in your test, you just cache your mock ...


1

If you run the code in a dev org and then capture the debug log you can see the full callout request and response in the corresponding CALLOUT_REQUEST and CALLOUT_RESPONSE log entries. Request <?xml version="1.0" encoding="utf-8"?> <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" ...


0

You only need to create single mock for Class A and then when you run your unit test for class B when it comes to HTTP Callout part in class A it will do that mock. 1) Class B calls method from Class A with Callout 2) When test comes to HTTP Callout it will implement the mock 3) Unit test continues as usual. I hope this helps you.


0

You can write one test class for class B and you need to include mock class where you need to specify the response inside mock class. Include this in test class and run this and confirm the code coverage. This is enough for deployment to Production. Hope it answer your question!!


0

Ok finally i fix the error. The solution: add this to the test @isTest(SeeAllData=true)


2

You will need to implement this validation on the front end, using a Visualforce page or Lightning component. Your custom UI - perhaps an override of the Edit action - can make a callout to validate data input prior to initiating DML at all. You then have full freedom to interact with the user's active browser session based upon the response from your web ...


Top 50 recent answers are included