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 hide or show Salesforce object through the apex code?

    Tagged: Account, Record Type, Salesforce Apex, Salesforce Apex Code, Salesforce Custom Object, Salesforce Trigger

    • Salesforce® Discussions

      How to hide or show Salesforce object through the apex code?

      Posted by Mohit on July 14, 2016 at 4:16 PM

      Hi All,

      How to hide or show Salesforce object  like account, contacts,  cases or any custom object through the apex code?

      Give your suggestion.

      Avnish Yadav replied 7 years, 2 months ago 5 Members · 5 Replies
      • Account
      • Record Type
      • Salesforce Apex
      • Salesforce Apex Code
      • Salesforce Custom Object
      • Salesforce Trigger
    • 5 Replies
    • Abhinav

      Member
      July 18, 2016 at 8:37 AM

      Hi,

      I don't think so this is possible through apex code. But there is one workaround we can change the current user profile through apex code.

    • Parul

      Member
      September 29, 2018 at 1:16 AM

      we can change the current user profile through apex code.

    • shariq

      Member
      September 29, 2018 at 10:35 AM

      You can change the profile of the user to hide the meta data.

      Hope this helps.

    • Avnish Yadav

      Member
      September 30, 2018 at 1:43 AM

      This can be achieved through the use of page layouts and record types. For example, a trigger that updates Lead No. by 1 (or not), could also set the Record Type to a layout that doesn't display lead number. While I'm all for using Visualforce as much as practical, there's times when some old-fashioned technology just works better.

    • Avnish Yadav

      Member
      September 30, 2018 at 1:44 AM

      Here is the code,

      You can create 2 record types that have different layouts.
      One layout has that custom field another one not get.

      You can using the Trigger are as follows,

       

      trigger trg_Lead on Lead (before insert)
      {
      for (Lead objLead : Trigger.new)
      {
      if(objLead.LeadSource != null)
      {

      // Check the Lead status is Phone,web or Mail & update the Lead No Custom Field.
      }
      else
      {
      RecordType[] rt = [select Id,Name from RecordType where Name =: 'Test Lead'];   //Test Lead is a RECORD TYPE.
      integer NsSize = rt.size();
      for(integer i = 0; i < NsSize ; i++)
      {
      objLead.RecordTypeId = rt[i].Id;
      }
      }
      }
      }

      Thanks.

    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 to Integrate Calendly with Salesforce: A Detailed Guide

    Blog in Salesforce integration

    In today’s fast-paced business environment, efficiency in scheduling and managing appointments is crucial. Integrating Calendly, a popular scheduling tool, with Salesforce, the leading customer relationship…

    Calendar Integration, Calendar Sync, Calendly, Calendly Events, Calendly Features
    Kizzy Consulting Jun 12, 2024
    526  Views
    Quote Line Items

    What are Quote Line Items in Salesforce

    Blog in Others, Salesforce

    What are the benefits of using quotes? When you have an opportunity, people want to know what choices you have. “Yeah, I'm interested in this,”…

    Case Number, Client, Contact, Contact Object's Lookup Area, Contact's Record
    krati vishnoi May 3, 2021
    15,287  Views
    sales process in salesforce

    Build a Sales Process in Salesforce | Learn How!

    Blog in Sales

    It is the process in which we can control the Picklist values of Stage field of Opportunity Object. We can create different sales processes for…

    Create Record Type, Create Sales Process, Opportunity Object, Page Layout, Page Layout Assignment
    Deepanshi Agarwal Jul 1, 2022
    3,047  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

    © 2025 - 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.