Is it possible to have the same apex controller being used by two different aura components? I'm trying to do that but the the component controller is getting an error response from the apex controller. This is my code:


        <div class="{!'slds-box slds-theme–alert-texture slds-theme–' + v.type}">
             <lightning:icon iconName="{! 'utility:'+ v.type }" size="medium"
                             alternativeText="{!v.type}" Class="iconContainer"/>&nbsp;
        <span class="slds-text-body–regular">
             <aura:unescapedHtml value="{!v.message}"/>
        <div class="slds-p-around--medium">
            <div class="slds-float--right">
                <lightning:button label="Close" 
                                  class="slds-button slds-button_brand"

Component JS Controller

handleRecordUpdated: function(component, event, helper) {

    var action = component.get("c.setCall");
     //set the parameters
         nif: component.get("v.simpleLead").NIF__c,
         country: component.get("v.simpleLead").Country
     console.log("Test2 " + component.get("v.simpleLead").Country);
     action.setCallback(this, function(response){
        var state = response.getState();
        if (state === "SUCCESS"){
                component.set("v.type", "success" );
                component.set("v.message", response.getReturnValue());
            } else if (response.getReturnValue()!="Success"){
                component.set("v.type", "error" );
                component.set("v.message", response.getReturnValue());

        else if (state === "ERROR") {
            component.set("v.type", "error" );
            var errors = response.getError();
                if (errors) {
                  if (errors[0] && errors[0].message) {
                     component.set("v.message",errors[0].message );//Fetching Custom Message.
         else {
              component.set("v.message", 'Request Failed!' );
    //Send action off to be executed


closeBtn : function(component, event, helper) {
    var dismissActionPanel = $A.get("e.force:closeQuickAction");

Apex controller

public with sharing class Ctrl_CallInformaDB {
public static string setCall(String nif, String country){

    string errorCode = InformaDB_API.CreditInfoProviderOrquestrator(nif,country);
    string returnMessage;
    List<Translate_Metadata__mdt> messages=[SELECT Value_EN__c FROM Translate_Metadata__mdt WHERE label = : errorCode];
    for(Translate_Metadata__mdt s : messages){
       System.debug('message ' + s.Value_EN__c);
       returnMessage = s.Value_EN__c;

    return returnMessage;
  • 1
    Yes, it's possible, but we would need to see a specific failing example to help you.
    – sfdcfox
    Commented Oct 16, 2018 at 8:14
  • I posted my code that is failing with an response.getState = Error.
    – I. Simoes
    Commented Oct 16, 2018 at 8:25
  • Can you check if you are passing the parameters correctly? Commented Oct 16, 2018 at 8:36
  • I did that and both parameters are passing the value correctly.
    – I. Simoes
    Commented Oct 16, 2018 at 8:39
  • Did you check debug log from developer console?
    – tugce
    Commented Oct 16, 2018 at 9:11

1 Answer 1


I had the nif field set to decimal, and the method was expecting a string. So one of the parameters was passing a decimal to the apex controller while this one was expecting a string, thus trowing an illegal argument error. Thank you for the help!


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .