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
sfdc_beginner7sfdc_beginner7 

How can we pass multiple parameters from Component to Apex class?

How can we pass multiple parameters from Component to Apex class .For ex I have a custom object ObjectA__c , the component  takes input from user and then I need to process these values in apex class and save to db . There are more than 10 fields which needs which needs to be set in apex. I cant pass these fields as parameters . I am not sure about wrapper class. Please let me know what is the best way to do it .
 
Soyab HussainSoyab Hussain
Hi,

Which component are you using,
Apex Components
Aura Components
LWC Components

Regards,
Soyab
sfdc_beginner7sfdc_beginner7
Hi Soyab I am using Aura components .
Ajay K DubediAjay K Dubedi
Hi,

Use force:recordData and send multiple parameter from lightning component to apex class using targetFields.

<force:recordData aura:id="recordLoader"
                      recordId="{!v.recordId}"
                      layoutType="FULL"                      
                      targetRecord="{!v.recordInfo}"                        
                      targetFields="{!v.ObjectA__c_Object }"    
                      />
                      
Click on the below link for more explain:
https://developer.salesforce.com/docs/component-library/bundle/force:recordData/documentation 

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Ajay Dubedi
www.ajaydubedi.com
sfdc_beginner7sfdc_beginner7
Is it possible to do it with a wrapper class?
ParthibanVParthibanV
You can pass,like below:

var action = component.get("c.saveAccounts");
action.setParams({
"value1": JSON.stringify(component.get("v.value1"),
"value2": JSON.stringify(component.get("v.value2"),
"value3": JSON.stringify(component.get("v.value3"),
});
action.setCallback(this, function(response) {
var state = response.getState();
if (state === "SUCCESS") {
}