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
EldonEldon 

Passing multiple values to server side apex controller

Hi,

I have passed a single value to my server side apex controller using the following code

action.setParams({ "searchKey" : elemVal });

Now i want to pass one more argument along with elemVal. I tried the following code but i am getting null.

action.setParams({ "searchKey" : elemVal },{"temp" : t}):

Please help
Best Answer chosen by Eldon
Balasubramaniam 07Balasubramaniam 07
Hi Eldon

Try the below snippet and let me know if it doesnt solve your issue.

  var action = component.get("c.getComponent");
        action.setParams({
            searchKey:elemVal,
            temp: t
        }); 


Thanks,
BaLa

All Answers

EldonEldon
i tried it in different lines also

action.setParams({ "searchKey" : elemVal });
action.setParams({"temp" : t}):

But then searchkey is showing null value.
Balasubramaniam 07Balasubramaniam 07
Hi Eldon

Try the below snippet and let me know if it doesnt solve your issue.

  var action = component.get("c.getComponent");
        action.setParams({
            searchKey:elemVal,
            temp: t
        }); 


Thanks,
BaLa
This was selected as the best answer
EldonEldon
Its working now.Thank you
Prasad N RPrasad N R
Balasubramaniam 07's answer worked for me. Upvoted that answer
Jaap ScheperJaap Scheper
i tried it in different lines also

action.setParams({ "searchKey" : elemVal });
action.setParams({"temp" : t}):

But then searchkey is showing null value.

Hi Eldon,
That is because you are using setParams twice. You are overwriting the first with the second.
If you want to use multiple calls, use the singular version (setParam, without the trailing s): 
action.setParam("searchKey", elemVal);
action.setParam("temp", t):