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

    What is the use of Salesforce Audit Fields and How to Enable These fields for your salesforce Org?

    What is the use of Salesforce Audit Fields and How to Enable These fields for your Salesforce Org?

    Blog in Salesforce Implementation

    So, first discuss how to enable "Salesforce Audit Fields” in our Org. Here are the following steps: First, click on “Setup” in Salesforce Org. Now,…

    CampaignMember, CaseComment, Content Version, Contracts in Salesforce, FeedComment
    Rajan Mar 16, 2018
    7,810  Views
    insert record in salesforce

    Insert Record by Email Service Attachments in Salesforce

    Blog in Others, Salesforce, Salesforce Apex

    Email Service Email service is the process that fulfills the business requirement by automated process service by using apex classes to process the content, attachment,…

    Attached CSV Files, Attachment, Attachments in Salesforce, Automated Process Service, Business Requirement
    Aditya Aug 7, 2020
    11,721  Views

    Mistakes To Avoid During Salesforce Data Migration

    Blog in Data Migration

    Data is the foundation on which all CRMs are built: start with poor data, you’ll get poor returns. That’s why data migration is such a…

    Cleaned Up your Data, Cleanse Data, CRM, CRM Migration, Custom Tools
    Mason Frank International Jun 24, 2021
    3,168  Views

    Popular Salesforce Videos

    What is CRM? | Salesforce Essentials 101 | Salesforce

    What is CRM? | Salesforce Essentials 101 | Salesforce

    Video in Salesforce Stories

     In this video, Salesforce Support explains how Customer Relationship Management (CRM) can help companies better engage with prospects, and customers, and streamline communications for business…

    Salesforce Training, Salesforce Tutorial, Salesforce Jobs, salesforce, CRM
    Tulika Wadhwani Oct 28, 2022
    1,673  Views
    Custom Portfolio in Salesforce | Mini Project | Salesforce Tutorials

    Custom Portfolio in Salesforce | Mini Project | Salesforce Tutorials

    Video in Others, Salesforce Training

    In this video, we will create a custom portfolio in Salesforce. We will create a custom community in Salesforce and customize it to create the…

    Salesforce Training, salesforce, Salesforce Video, Salesforce Learning, Portfolio
    Kapil Oct 8, 2020
    4,000  Views
    Pass Record Id into Flow from Record | Salesforce Tutorial

    Pass Record Id into Flow from Record | Salesforce Tutorial

    Video in Salesforce Training, Salesforce Automation

    Passing record ids is a technique that every flow master needs to know to use flows to their full potential. In this video, we go…

    Salesforce Training, Salesforce Tutorial, salesforce knowledge, Salesforce Flow, Salesforce Video
    Warren Nov 4, 2020
    8,099  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.