Toggle Side Panel

  • Home
  • Articles
    • All Articles
    • Blogs
    • Videos
    • Infographics
  • 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
  • Marketplace
  • Advertise With Us
  • Contact Us
  • Discussions
More options
    Sign in Sign up
    • Home
    • Articles
      • All Articles
      • Blogs
      • Videos
      • Infographics
    • 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
    • Marketplace
    • Advertise With Us
    • 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 7 years, 7 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

    application solution

    Popular Salesforce Blogs

    How Nonprofits Benefit from Salesforce and Capsule Services

    Blog in Salesforce

    Like many businesses, nonprofits also benefit from using a CRM for managing their funding. While Salesforce for small businesses focuses mainly on sales and growing…

    Best Practices, Business, Capsule Eengagements, Capsule Engagement, Capsule Services
    Apphienz Nov 8, 2021
    2,308  Views

    Quote Templates in Salesforce: What Do You Need to Know to Use Them Right

    Blog in Salesforce Tools

    The C, P, and Q in CPQ stand for Configuration, Pricing, and Quote—a powerful combination that simplifies the proposal process. Creating accurate and professional-looking quotes…

    Branding Consistency, Business Software, Configure Price Quote, Configure Pricebook, CPQ
    Sculptor CPQ Jul 11, 2024
    918  Views
    Salesforce Integration Services

    Leverage Salesforce Integration Services to Retain Valuable Customers

    Blog in Salesforce integration

    We all have heard that integrating Salesforce with other applications provides organizations much greater operational visibility and access to unknown resources. It offers innovative products…

    Applications, Basecamp, Books, Business, Business Complexities
    Technosip Aug 17, 2021
    2,799  Views

    Popular Salesforce Videos

    How to Establish a Many to Many Relationship in Salesforce?

    How to Establish a Many to Many Relationship in Salesforce?

    Video in Salesforce Implementation, Salesforce Training

    You can use master-detail relationships to model many-to-many relationships between any two objects. A many-to-many relationship allows each record of one object to be linked…

    Salesforce Beginner Tutorial, Salesforce Tutorial for Beginners, Salesforce Records, Salesforce Customization, Salesforce Custom Objects
    Nauman Feb 13, 2018
    1,901  Views
    What is the Difference Between Object and Database in Salesforce?

    What is the Difference Between Object and Database in Salesforce?

    Video in Salesforce Admin

    Salesforce Object: Salesforce Object are database table which give permission to store data that is specific to organization. Salesforce Database: The organized collection of object…

    Salesforce Training, Salesforce Online Training, Apex Class, Salesforce Database, Salesforce Adminstrator
    CRS Apr 18, 2022
    1,862  Views
    Integer Datatype | Primitive Datatypes in Apex | Salesforce Development Tutorials

    Integer Datatype | Primitive Datatypes in Apex | Salesforce Development Tutorials

    Video in Salesforce Apex

    Shrey covered the following questions in this video: What are the different types of Datatype? What are Primitive Datatypes? What is the Long datatype? What…

    Salesforce Training, Salesforce Tutorial, Salesforce Development, Salesforce Apex, salesforce
    S2 May 2, 2022
    1,695  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®.

    Try AuditMyCRM - It is a Salesforce CRM Audit tool which comprehensively scans your Salesforce org and gives you the list of errors or warnings you need to take care of.
    We use cookies to enhance your browsing experience. Please see our privacy policy if you'd like more information on our use of cookies.