Thursday, April 20, 2023

How To Send Set of Ids or Set of Records From Lwc Component To Apex Method

If you're planning to use the set as the one of the parameter of your apex function and the same need to passed from lwc js look at these limitations below.

  • By default @AuraEnabled methods will not accept /allow to use the set of Records as the parameter. 
  • In detail, it's not only support set of Records even if you try to pass of set of Ids, set of strings and set of Records it will not work because it's doesn't support set data type it self.
The work around for this is 

  • The @AuraEnabled method again will support the list as a parameter so you either convert parameter from set to list is one option.
  • You can also try out the convert the set of Records into string in lwc using the Json.stringify() and change the your apex method param to string and inside method you can deserialize the string to set in side the apex method. 

1 comment: