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

    7 Reasons Why Your Business Needs to Know Salesforce

    Blog in Salesforce

    The main use of Salesforce is to create customer relationship management (CRM) software that facilitates break down the technology between divisions to give firms a…

    Automation, Big Business, Business, Business Needs, Businesses
    Hamza Abbasi Sep 22, 2021
    3,506  Views

    Salesforce Summer'21 Top Pardot Release Features

    Blog in Salesforce Products, Salesforce Releases

    With the new Summer ‘21 Salesforce release, you get the most out of your email campaigns, and have more authority over your instance, and boost…

    Cleansing Data, Configuration Authority, Configuration Files, Criteria Fields, custom Reports
    Apphienz Aug 6, 2021
    1,964  Views

    All You Need To Know About Salesforce Health Cloud 2.0

    Blog in Salesforce, Salesforce Cloud Platform

    Health Cloud 2.0, a solution designed to empower businesses and governments to provide better health and safety for their employees, consumers, and communities, was unveiled…

    Appointment Scheduling, Business, Business Operations, communities, Connected Health
    Apphienz Oct 6, 2021
    2,467  Views

    Popular Salesforce Videos

    Salesforce Placement Success Story By One of our Student

    Salesforce Placement Success Story By One of our Student

    Video in Salesforce Training

    Want to learn about Salesforce and planning to make a career in the Salesforce Industry?  Join this useful group for Salesforce job & career info.

    Salesforce Training, Salesforce Tutorial, Salesforce Jobs, salesforce, Salesforce Industry
    Intelogik Sep 19, 2022
    1,149  Views
    Building Slack Apps with Apex on Salesforce

    Building Slack Apps with Apex on Salesforce

    Video in Salesforce Training, Salesforce Apps

    Slack has traditionally been associated more with non-Salesforce backends such as AWS. Now that Slack is a Salesforce product, Salesforce developers are probably curious about…

    Salesforce Training, Salesforce Tutorial, Salesforce Developers, Salesforce Video, salesforce product
    Prafull Apr 26, 2022
    2,272  Views
    How I Really Feel About Salesforce

    How I Really Feel About Salesforce

    Video in Salesforce Stories

    A deep dive into the state of the Salesforce industry in 2021, such as: - Is Salesforce going to crash in the foreseeable future? -…

    Salesforce Training, salesforce, Salesforce Industry, Salesforce Video, Salesforce Learning
    Nauman Aug 31, 2021
    2,528  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.