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, 2 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

    Salesforce Announces: Einstein GPT integration with Flow Data Cloud

    Blog in Salesforce integration

    We are thrilled to bring you the latest news in the world of B. In a groundbreaking move, Salesforce has announced the integration of Einstein…

    Artificial Intelligence, Business Planning, Business Workflows, Cloud Analogy, Competitive Advantage
    Chris Aug 18, 2023
    1,834  Views
    How to Use Wrapper Class In Salesforce Lightning Component?

    How to Use Wrapper Class In Salesforce Lightning Component?

    Blog in Lightning, Salesforce Implementation

    How to Use Wrapper Class In Salesforce Lightning Component? A wrapper or container class is a class, a data structure, or an abstract data type…

    Implement Salesforce Lightning, Salesforce Lightning Component, Salesforce Lightning Experience, Wrapper Class, Wrapper Class in Lightning Component
    Aman Apr 9, 2018
    23,690  Views
    Salesforce Consultant

    Salesforce Consultant: 5 Things To Consider

    Blog in Salesforce Consultant

    Hire? Outsource? Contractors? Managed Services? Consultants? One thing that isn’t always top-of-mind when implementing a powerful CRM like Salesforce is the best strategy to keep…

    Bug Fixing, Business, Business Model, Business Requirements, Certified Salesforce Consulting Partner
    SaltClick Mar 7, 2022
    3,671  Views

    Popular Salesforce Videos

    Generative AI: What Are Its Benefits For Businesses?

    Generative AI: What Are Its Benefits For Businesses?

    Video in Others

    Imagine a world where computers can help businesses come up with creative ideas, solve tricky problems, and even predict what customers might want next. That's…

    Salesforce Tutorial, salesforce, Artificial Intelligence, Salesforce Video, Technology
    Cyntexa Nov 1, 2023
    1,149  Views
    Salesforce Admin Freelancing - $32,000 in 1 Month - Learn How You Can Do It

    Salesforce Admin Freelancing - $32,000 in 1 Month - Learn How You Can Do It

    Video in Salesforce Training

    I made $32,000 last month, working only 20 hours per week. I want to show you how to do the exact same thing! Pricing increases…

    Salesforce Training, salesforce, Salesforce Admin, Salesforce Learning, Salesforce Job
    Bradley Aug 5, 2020
    3,289  Views
    Running a New Report in Salesforce

    Running a New Report in Salesforce

    Video in Salesforce Training

    After logging into Salesforce, Go to the reporting section by clicking on the Reports tab at the top of the page, Click on the New…

    Salesforce Training, Salesforce Tutorial, salesforce, Salesforce Video, Salesforce Learning
    Abhishek Apr 20, 2021
    1,466  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.