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
Michael_MantouvalosMichael_Mantouvalos 

How to call a function with parameters from another function in aura jsController of a components

Hello everybody!

I have a component that has a jsController. Inside the controller there my "doInit" function. 

I also have created another  function with 4 parameters

printFunction : function ( param1, patam2, param3, param4){
.......
}

Is there a way to call printFunction having also defined the parameters,  from  inside "doInit" function?

Thanks in advance!

AnudeepAnudeep (Salesforce Developers) 
Here is an example that I found online 
<aura:component>
    <!--Component Start-->
    <div class="slds-m-around_xx-large">
        <lightning:button variant="Brand" class="slds-button" label="Submit" onclick="{!c.methodOne}"/>
    </div>
    <!--Component End-->
</aura:component>
({
    //Method One
    methodOne : function(component, event, helper){
        //Call methodTwo from methodone
        var action = component.get('c.methodTwo');
        $A.enqueueAction(action);
    },
     
    //Method Two
    methodTwo : function(component, event, helper){
        alert('Method 2');
    }
})
I also recommend reviewing the following posts

Lightning - JS controller invoking its own method

Call another method from a method in the same Lightning controller

Let me know if this helps, if it does, please close the query by marking it as solved. It may help others in the community. Thank You!
Michael_MantouvalosMichael_Mantouvalos
hmm.. the problem i see is that method2 has not custom parameters. I want method2 to be like this :
method2 : function (name, lastname ,age, height){
}

I think i found the solution to one of the links you send though... 
You cannot create a custom parameter function i Js Controller, ONLY in helper. So in my situation i did something like :

JsController :
({
doInit : function(component, event, helper){
         var name = 'alex';
         var lastname ='johnson';
         var age = 30;
         var height = 190;
         helper.method2(component, event, name, lastname, age, height);
},
})

helper:
({
method2 : function (component, event, name , lastname, age, height){
.............
}
})



And it worked. Thank you for information
 
Have a good one!