Activity Forums Salesforce® Discussions What is the need of wrapper class in salesforce ?

  • Deepak

    Member
    February 28, 2020 at 6:34 am

    Hi Kirandeep,

    We have collections like “list” which can store only one type of data, suppose we have ‘Account’ or ‘Contact’. List<Account> will hold only accounts and List<Contact> will hold only contacts in it. But what if you want to show data on the table that should show account records as well as address data? iterating over List<Account> will only allow account records and no contact data.

    To solve this problem, we can create a wrapper class having variables account and contact and then create the list of that wrapper class. This may sort out your problem easily might look difficult in starting but as soon as you start using wrapper class you will try to again use it.

    For more information,checkout my blog available on Forcetalks.

  • Manish

    Member
    February 28, 2020 at 7:26 am

    If We want to Display records of sObject on a single page then we need Wrapper Class.

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos