Toggle Side Panel

  • Blogs
  • Consultants
    • Salesforce Product Expertise
      • Top Salesforce ConsultantsTop Salesforce Consultants
      • Marketing Cloud ConsultantsMarketing Cloud Consultants
      • Service Cloud ConsultantsService Cloud Consultants
      • Experience Cloud ConsultantsExperience Cloud Consultants
      • Analytics Cloud ConsultantsAnalytics Cloud Consultants
    • Salesforce Industry Expertise
      • Non-Profit Cloud ConsultantsNon-Profit Cloud Consultants
      • Financial Service Cloud ConsultantsFinancial Service Cloud Consultants
      • Health Cloud ConsultantsHealth Cloud Consultants
      • Commerce Cloud ConsultantsCommerce Cloud Consultants
      • Manufacturing Cloud ConsultantsManufacturing Cloud Consultants
    • Salesforce Experts by Location
      • USATop Salesforce Consultants in USA
      • IndiaTop Salesforce Consultants in India
      • AustraliaTop Salesforce Consultants in Australia
      • United KingdomTop Salesforce Consultants in UK
      • CanadaTop Salesforce Consultants in Canada
  • Webinars
  • Contact Us
  • Discussions
More options
    Sign in Sign up
    • Blogs
    • Consultants
      • Salesforce Product Expertise
        • Top Salesforce ConsultantsTop Salesforce Consultants
        • Marketing Cloud ConsultantsMarketing Cloud Consultants
        • Service Cloud ConsultantsService Cloud Consultants
        • Experience Cloud ConsultantsExperience Cloud Consultants
        • Analytics Cloud ConsultantsAnalytics Cloud Consultants
      • Salesforce Industry Expertise
        • Non-Profit Cloud ConsultantsNon-Profit Cloud Consultants
        • Financial Service Cloud ConsultantsFinancial Service Cloud Consultants
        • Health Cloud ConsultantsHealth Cloud Consultants
        • Commerce Cloud ConsultantsCommerce Cloud Consultants
        • Manufacturing Cloud ConsultantsManufacturing Cloud Consultants
      • Salesforce Experts by Location
        • USATop Salesforce Consultants in USA
        • IndiaTop Salesforce Consultants in India
        • AustraliaTop Salesforce Consultants in Australia
        • United KingdomTop Salesforce Consultants in UK
        • CanadaTop Salesforce Consultants in Canada
    • Webinars
    • Contact Us
    • Discussions
    Close search

    Activity › Forums › Salesforce® Discussions › How to define a custom type for both account and contact object using Wrapper class in Salesforce?

    Tagged: Account Object, Contact Object, Salesforce Apex, Wrapper Class, Wrapper List

    • Salesforce® Discussions

      How to define a custom type for both account and contact object using Wrapper class in Salesforce?

      Posted by chanchal kumar on July 2, 2018 at 12:28 PM

      How to define a custom type for both account and contact object using Wrapper class in Salesforce?

      shradha jain replied 8 years, 1 month ago 2 Members · 1 Reply
      • Account Object
      • Contact Object
      • Salesforce Apex
      • Wrapper Class
      • Wrapper List
    • 1 Reply
    • shradha jain

      Member
      August 6, 2018 at 7:09 AM

      Hello Chanchal,

      You can refer to the following example to  define a custom type for both acccount and contact object using wrapper class:

      public with sharing class conacc {

      public List<MyWrapper> wrapper {get; set;}

      public List<Account> accLst1 {get; set;
      public List<Contact> conLst1 {get; set;}

      public conacc ()

      {
      accLst1 = [select id,Name from Account ] ;
      conLst1 = [select Id,Name from contact where AccountId IN : accLst1 ] ;
      wrapper = new List<MyWrapper>() ;
      for(Integer i=0 ; i < 20; i++)
      wrapper.add(new MyWrapper( conLst1, accLst1[i])) ;
      System.debug('----------'+ wrapper);
      }
      public class MyWrapper
      {
      public Account accRec1 {get; set;}
      public List<Contact> conRec1 {get; set;}
      public MyWrapper( List<Contact> con ,Account acc )
      {
      accRec1 = acc ;
      conRec1 = con ;
      }

      }

      }

    Log In to reply.

    • Public
    • All Members
    • My Connections
    • Only Me
    • Public
    • All Members
    • My Connections
    • Only Me
    • Public
    • All Members
    • My Connections
    • Only Me

    Popular Salesforce Blogs

    When Should We Use Record Types In Salesforce?

    When Should We Use Record Types In Salesforce?

    Blog in Salesforce Implementation

    You can get lots of benefits of Record Types in Salesforce but if you do not implement it correctly, then they can create some complexities…

    Picklist, Picklist Values, Record Related List, Related Fields, Salesforce Custom Fields
    Prafull Jan 24, 2018
    16,835  Views

    Salesforce Development Service Provider: How Businesses Can Build Better CRM Solutions

    Blog in Others

    Customer relationship management plays an important role in helping businesses manage customer interactions, improve sales processes, and deliver better experiences. As companies continue to adopt…

    Shivansh Aug 12, 2026
    139  Views
    Boost Your Sales with Effective Email Pitch Strategies in Salesforce

    Boost Your Sales with Effective Email Pitch Strategies in Salesforce

    Blog in Others

    Clear communication with prospects is the key to building relationships and increasing sales, especially for B2B businesses. As B2B sales involve higher transaction value and…

    Authority, Automation Features, B2B Businesses, Bounce Rates, Bulk Emails
    Saasguru Apr 20, 2023
    1,638  Views

    Popular Salesforce Videos

    How to Delete Preloaded Sample Data in New Salesforce Organizations

    How to Delete Preloaded Sample Data in New Salesforce Organizations

    Video in Salesforce Training

    When Users begin a trial or subscription with Salesforce, their org comes with a set of sample data. This data includes Accounts, Contacts, and Opportunities.…

    salesforce, Salesforce Video, Salesforce Learning, Salesfore Training, Data
    Jogender May 25, 2021
    3,636  Views
    What is Salesforce Development? | Salesforce Developer Course

    What is Salesforce Development? | Salesforce Developer Course

    Video in Salesforce Development

    In this video, Shrey has given a detailed overview of the Salesforce Development Course. You will learn the following topics from this course: Apex basics…

    Salesforce Training, Salesforce Development, Visualforce, SOQL, Apex Basics
    Prafull Jun 15, 2021
    1,500  Views
    Introduction to Salesforce OmniStudio | Salesforce Industries

    Introduction to Salesforce OmniStudio | Salesforce Industries

    Video in Salesforce Products

    Introduction to Salesforce OmniStudio: The Salesforce OmniStudio digital engagement suite makes it easy to click-configure rich, consumer-grade user experiences based on objects, APEX classes, REST…

    Salesforce Training, Salesforce Tutorial, Salesforce Integration, Salesforce Video, Salesforce Learning
    Prafull Apr 22, 2021
    5,272  Views
    Footer Forcetalks logo

    support@forcetalks.com

    • twitterx

    Quick Links

    Advertise with Us

    Salesforce® Articles

    Dreamforce 2023

    Top Salesforce® Bloggers 2023

    Top Salesforce Consultants

    Get Listed

    Company

    Contact Us

    About Us

    Privacy Policy

    Terms & Conditions

    InsightHub

    Salesforce Blogs

    Salesforce Videos

    Salesforce Groups

    Salesforce Jobs

    © 2026 - Forcetalks ● All Rights Reserved

    Salesforce® is a trademark of Salesforce® Inc. No claim is made to the exclusive right to use “Salesforce”. Any services offered within the Forcetalks website/app are not sponsored or endorsed by Salesforce®.

    We use cookies to enhance your browsing experience. Please see our privacy policy if you'd like more information on our use of cookies.