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

    Low-Code vs. Pro-Code: Choosing the Right Approach on Salesforce Platform

    Low-Code vs. Pro-Code: Choosing the Right Approach on Salesforce Platform

    Blog in Salesforce

    Low-code and pro-code development models represent two powerful ways to deliver solutions on the Salesforce platform. As organizations accelerate digital innovation, the question of which…

    Code, Platforms, Salesforce
    Morgan Sep 11, 2025
    1,082  Views
    Salesforce Analytics Cloud and Integration Cloud | The Ultimate Guide

    Salesforce Analytics Cloud and Integration Cloud | The Ultimate Guide

    Blog in Salesforce

    Salesforce Analytics Cloud, also known as Einstein Analytics, is a powerful data analytics tool that helps businesses make better decisions by providing them with real-time…

    APIs, Application Networks, Apps, Artificial Intelligence, Automate Service Processes
    bhawana Apr 13, 2023
    1,990  Views

    Unpacking Salesforce Experience Cloud: A Comprehensive Analysis

    Blog in Salesforce

    Introduction to Salesforce Experience Cloud Salesforce Experience Cloud, formerly branded as Salesforce Community Cloud, is a powerful tool created by Salesforce that provides businesses the…

    AppExchange Integrations, Better Engagement, Brand Consistency, Cost-effective Solution, Custom Dashboard Configuration
    CRMJetty Aug 12, 2023
    1,829  Views

    Popular Salesforce Videos

    Get Started with Salesforce Commerce Cloud Einstein Product Recommendations

    Get Started with Salesforce Commerce Cloud Einstein Product Recommendations

    Video in Salesforce Cloud Platform

    Personalize the shopping experience for your customers with Commerce Cloud Einstein Product Recommendations. Drive conversions, enhance product visibility and increase revenue per visit with AI-driven…

    Salesforce Training, Salesforce Einstein, Salesforce Commerce Cloud, Salesforce Video, Testing
    Abhishek May 13, 2021
    4,795  Views
    Use Salesforce Notification Builder to Get Notifications to the Right Users in the Right Apps

    Use Salesforce Notification Builder to Get Notifications to the Right Users in the Right Apps

    Video in Salesforce Training, Salesforce Apps

    Did you know you can use Notification Builder to create custom notifications for teams, task queues, and public groups? You can also replace standard notifications…

    Salesforce Training, salesforce, Salesforce Video, Salesforce Learning, Salesforce Notification Builder
    Prafull Jul 28, 2020
    2,204  Views
    How Easy (or Difficult) is it to Transition from Salesforce Classic to Lightning Experience?

    How Easy (or Difficult) is it to Transition from Salesforce Classic to Lightning Experience?

    Video in Lightning

    This video answers the question of: How Do You Transition Your Company from Salesforce Classic to Lightning Experience? ▪️ How difficult is it? ▪️ How long should…

    Salesforce Lightning, Salesforce Lightning Experience, Salesforce Implementation, Salesforce CRM, Learn Salesforce
    Pooja Feb 26, 2018
    2,401  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.