You need to sign in to do that
Don't have an account?
hjv6606
External API call on page load
Hello,
I am trying to accomplish the following:
I am trying to accomplish the following:
- Call an external REST API on Account page load
- JSON response will be parsed into a table within a custom object
no if you are using lightning
then just create a lighitng componet
<aura:component implements="flexipage:availableForAllPageTypes,force:hasRecordId" access="global" >
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
</aura:component/>
in you JS file
({
doInit: function(component, event, helper) {
console.log(component.get("v.recordId"));
helper.mymethod(component);
},
})
helper
mymethod: function(component)
{
var action = component.get("c.GetAccountInfo"); // call your apex class method
action.setParams({
AccountId : component.get("v.recordId") // pass the paramters
});
action.setCallback(this, function(a) {
//handel the responce
}
$A.enqueueAction(action);
}
All Answers
So i assume from "Account page load" you mean when ever standard account page layout load ?
You are using lighting or standard ?
you can add a VF page or lighitng component in standard page layout and call you apex code on load of VF / lighting component
if you are in classic then you can create a VF page and use account as standard controller in that VF page, that will allow you to use that VF page to add inside standard pagelayout
if you are using lighitng then you can just edit the page and drag you lighitng component on right side panael
you have to make sure your lighitng component implement
If your component is available for both record pages and any other type of page, implement flexipage:availableForAllPageTypes.
If your component needs the record ID, also implement the force:hasRecordId interface
no if you are using lightning
then just create a lighitng componet
<aura:component implements="flexipage:availableForAllPageTypes,force:hasRecordId" access="global" >
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
</aura:component/>
in you JS file
({
doInit: function(component, event, helper) {
console.log(component.get("v.recordId"));
helper.mymethod(component);
},
})
helper
mymethod: function(component)
{
var action = component.get("c.GetAccountInfo"); // call your apex class method
action.setParams({
AccountId : component.get("v.recordId") // pass the paramters
});
action.setCallback(this, function(a) {
//handel the responce
}
$A.enqueueAction(action);
}