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, 3 months 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

    retail banking

    Retail Banking Powered by Salesforce

    Blog in Salesforce Cloud Platform

    Background Salesforce has been around for a while, but in recent years we’re seeing a boom in its popularity. Why is that the case? The…

    Bank Customers, Banking Products and Services, Business Communication, Business Data, Client
    Tetiana Mykhailyk Jun 16, 2021
    1,755  Views

    How to Pass the Salesforce Administrator Certification Exam in 28 Days?

    Blog in Salesforce

    The Salesforce Administration Certification Exam is a great indicator that an individual has a foundational understanding of the Salesforce platform, and the admin certification is…

    Career in Salesforce, Certification Best Practices, Certification Exam, Certification in 28 Days, Certification Roadmap
    Ray brad Sep 17, 2024
    810  Views
    Summer ’21 Release

    Salesforce Summer ’21 Release - Highlights You Need to Know About

    Blog in Salesforce Releases

    It’s time for Salesforce’s Summer ’21 Release! Salesforce has once again built a bunch of new features and improvements to ensure we, the users and…

    Commerce Cloud, Commerce PWA Kit, Complex Integrations, Consumer Goods Cloud, CPQ
    DB Jun 10, 2021
    3,239  Views

    Popular Salesforce Videos

    Should You Learn Salesforce in 2020?

    Should You Learn Salesforce in 2020?

    Video in Salesforce Stories

    The Salesforce industry has been the best-kept secret of our careers with average salaries near $150,000 - but is it still a good technology to…

    Nauman Jun 18, 2020
    1,525  Views
    How to Create an Automated File Import in Salesforce Marketing Cloud

    How to Create an Automated File Import in Salesforce Marketing Cloud

    Video in Marketing, Salesforce Training

    Cameron Robert shows how to create an automation to import files from your FTP into Data Extensions in Salesforce Marketing Cloud. File Import Automations are…

    Salesforce Training, Salesforce Marketing Cloud, Salesforce Video, Salesforce Learning, Training
    Cameron Sep 17, 2021
    3,303  Views
    From ₹5000 Salary to Salesforce MVP - Journey of a Small Village Boy

    From ₹5000 Salary to Salesforce MVP - Journey of a Small Village Boy

    Video in Others, Salesforce Stories

    Story of Salesforce MVP Amit Singh Session Includes: [00:14:00] ? How Amit Singh started his career in Salesforce as a Fresher. [00:30:45] ? How Amit…

    Salesforce Development, Salesforce Jobs, salesforce, Salesforce Developers, Salesforce Video
    Shubham Mar 1, 2021
    3,256  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.