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 Integrations

    Salesforce Integrations - Enterprise Portfolio Considerations

    Blog in Salesforce integration

    Why Salesforce Integration? What are the Benefits? We live in a world where even the smallest of organizations have multiple systems in their IT Footprint…

    APIs, AppExchange, Apps, Authorized Data, Cloud-based Salesforce Shield Platform Encryption
    Anita Sep 26, 2022
    3,124  Views

    5 Reasons why you Shouldn’t Ignore Salesforce Google Ads Integration

    Blog in Salesforce integration

    Salesforce Google Ads Integration Marketers set aside a sizeable amount of their total marketing budgets to Google Ads. However, there have been huge challenges with…

    GA Connector in Salesforce, Google Analytics, Marketing Campaigns, ROI, Sales cloud of Salesforce
    DemandBlue Jan 16, 2019
    3,396  Views
    Flows in Salesforce

    Flows in Salesforce - Some Expert Tips to Take On

    Blog in Salesforce, Salesforce Apex

    Here mention some tips on flows which is very useful for everyone to start working on Flows and also mention some use cases to practice…

    Campaigns, Chatter, Contact Namem, Data Loads, Flows
    SF Dec 28, 2022
    3,973  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.