function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Navin Ganeshan 10Navin Ganeshan 10 

Call Rest API when record is opened

Hi, 

I am creating a class that would call a rest API for some data, store in a custom object and display as a related lists in a case. However, need to figure out when the API call would be made. 

One of the solutions I thought was to create a lightning web component and embed that into case's record screen. When user opens the case and lwc loads, call the API to refersh the data. 

However, i am new to lwc, so thinking in terms of time to market. Question for this group, is it possible to call the API when a user clicks on the case id and case's record screen opens. if yes, then how should that be implmented. 

I dont have any code to share, as this is very much in my head for now!

Thanks,
Navin
 
ANUTEJANUTEJ (Salesforce Developers) 
Hi Navin,

Although this is similar to your idea you can also implement the same functionality in lightning components and embed the component to perform certain function or trigger an event during the initialization of the page.

I found this below link which shows the initialization of a lightning component, please find the link for it below:

>> https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/js_cb_init_handler.htm

I hope this was useful in case if you found it handy can you please choose this as best answer so that it can be used by others in the future.

Regards,
Anutej
EranVEranV
How about an "empty" Visualforce to embed in the record detail page, with a controller that calls the API?