Skip to main content
KARTIK BHALLA が「#Apex」で質問
I am not able to understand from any of the articles on the internet. plz can any one explain the syntax and with example like I am getting confused why and when do we use contructor in wrapper class and can we write wrapper class without constructor, what exactly the wrapper class returns.. an object? or list of objects?  Please any can explain me with an easy practical example covering everything.. it will be really helpful. I have to use it in my aura component

 
2 件の回答
  1. 2024年1月2日 6:12

    Hello @KARTIK BHALLA,

    Basically a wrapper class is used to meet the different requirements like i worked on a scenario where i getting the account id as a input and i need to return the account name, related opportunity count , and related contact  is present or not, so if we think it is possible by soql query , but instead wrapper class gave us a simple syntax we need to :

    1. Declare Variables in Wrapper Class:

    2. Create a Method Accepting Parameters:

    3. Create an Object of Wrapper Class:

    4. Assign Values to Wrapper Class Variables:

    5. Return the Wrapper Class Object:Hello ,Basically a wrapper class is used to meet the different requirements like i worked on a scenario where i getting the account id as a input and i need to return the account name, related opportu

    also refer:

    https://youtu.be/CWoAGoLjr7c?si=trNp9IpzkfI1cCDW
0/9000