Please see the following scenario.

The client wants to implement a custom LWC component - Activity Timeline that would fetch data via REST callout/callouts to API Gateway.

Going into detail - there would be 10 different endpoints returning different data groups (customer appointments, customer loans, customer personal events - birthday, anniversaries etc.) and another 10 endpoints returning the details of an item in a specific data group.

The timeline would contain different items, but each item would have a detail button that would open a subsection with additional data. Also, the user would be able to filter on the existing records displayed in the Activity Timeline component.

Now, the JSON structure looks like this:

Endpoint No. 1 returns a list of general data along with ID of a single event, which is then used as a parameter for the second endpoint

         "type":"business appointment",
         "type":"personal appointment",

Endpoint No. 2 returns data specific to each item

      "duration":"2 hours",
      "topic":"business appointment",
      "recommended_product":"premium loan"

This means that I need to send 1 callout to receive a list of generic data. Then, if I want to get the details that would be displayed in the expanded subsection, I will have to send another callout for each item with the ID of the item as a parameter received from endpoint No. 1.

Should I make all callouts when rendering the component, meaning that I would gather all items and also the details OR should I send a single callout on clicking of the details button?

My train of though is this:

  • Execute the callouts from the server, not from the client, i.e. from Apex, not from Javascript, to make the component as secure as possible.
  • Given the fact that there are no limits on outbound callouts from Salesforce, execute all callouts on rendering of the component and pass the resulting JSON to the LWC component client controller, where the UI filtering logic would be present. Check limits on the side of the API gateway to see how many inbound calls from Salesforce is it allowed to accept.
  • Somehow (I don't know how at this moment) I need to calculate the peak size of data received from the callouts if all are sent on rendering of the component - the size of data is important to know if I there is a chance to exceed the heap size limit (6MB) if I perform all callouts at once.

I will be happy about any response/experience/opinions.

  • would response will change based on user or the record where lwc is placed? May 28, 2023 at 8:11
  • @sanketkumar The Custom Activity Timeline would be on Account record. Response data will be based on Account ID.
    – DevelBase2
    May 28, 2023 at 16:06


You must log in to answer this question.

Browse other questions tagged .