You need to sign in to do that
Don't have an account?
Error in $A.getCallback() [Cannot read property 'setParams' of undefined] Callback failed: apex://LighteningComponentControllerList/ACTION$updateStatus Failing descriptor: {markup://c:MyListCompone
I am Passing Values From VF page to Componnet , I want to dsiplay toaster message But it is showing the above Error :
VF Page :
<apex:page standardController="Account" extensions="ListViewButtonController" recordSetVar="accs" >
<apex:includeLightning />
<script type="text/javascript">
var jsAccounts= new Array();
<apex:repeat value="{!idsList}" var="accId">
jsAccounts.push('{!accId}');
</apex:repeat>
$Lightning.use("c:SampleApp", function() {
$Lightning.createComponent("c:MyListComponent",
{ "accountId" :jsAccounts},
);
});
</script>
</apex:page>
Component :
<aura:component implements="flexipage:availableForAllPageTypes,force:appHostable" access="global" controller="LighteningComponentControllerList">
<aura:attribute name="listofAccounts" type="set" />
<aura:attribute name="accountId" type="List" />
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
</aura:component>
Controller :
({
doInit : function(component, event, helper) {
var accountId = component.get("v.accountId");
var ids=new Array();
for (var i= 0 ; i < accountId.length ; i++){
ids.push(accountId[i]);
}
var idListJSON=JSON.stringify(ids);
var action = component.get("c.updateStatus");
action.setParams({
"idsListValues":idListJSON
});
action.setCallback(this, function(actionResult) {
var state = actionResult.getState();
if(state === "SUCCESS") {
var toastEvent = $A.get("e.force:showToast");
toastEvent.setParams({
"title": "Succés",
"message": "helloo",
"type": "success"
});
toastEvent.fire();
}
});
$A.enqueueAction(action);
}
})
Greetings!
Please post your apex class code.
There are some parameter problems with your apex method.
Make sure in updateStatus method, there should be only one parameter name idsListValues of String type, not List type.
Thank you!
Regards,
Suraj Tripathi
public class LighteningComponentControllerList {
@AuraEnabled
public static void updateStatus(List<String> idsListValues){
List<Account> listtoUpdate = new List<Account>() ;
for(Account acc : [SELECT ID,Name,Rating from Account where Id in :idsListValues ]){
acc.Rating = 'Hot' ;
listtoUpdate.add(acc) ;
}
update listtoUpdate ;
}
}
Thank you!
Regards
Suraj Tripathi.