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

    Salesforce Reports

    How To Export Salesforce Reports To Excel

    Blog in Salesforce integration

    Excel remains one of the leading tools for short and valuable reports. The training cost is low, and it’s easy to use. Salesforce works perfectly…

    API, Automated Exports, Bulky Reports, CSV File, CSV Formats
    Olena Prykhodko Jun 20, 2022
    4,873  Views

    Salesforce to MySQL: Steps to Integrate Data Easily

    Blog in Salesforce

    Are you attempting to connect Salesforce to MySQL? If so, you've arrived at the right. Salesforce seems to be a virtualized Customer Management (CRM) technology…

    APIs, billing, Business Environment, Cloud-based Customer Relationship Management, Cloud-based Technology
    vunnam Nov 2, 2021
    7,414  Views
    Page Layouts in Salesforce

    Page Layouts in Salesforce - Here's All You Need to Know

    Blog in Salesforce

    Introduction Page layout is an important concept introduced by Salesforce. It is mainly used to maintain the appearance of your object records detail page. It…

    Classic Experience, Created Fields, Custom Links, Customize Buttons, Fields
    Rajat Shende Feb 28, 2022
    4,671  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.