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

    Automate Call Logs Using RingCentral for Salesforce

    Automate Call Logs Using RingCentral for Salesforce

    Blog in Salesforce Implementation, Salesforce integration, Salesforce Tools

    Hi All, RingCentral one way solution for calling from Salesforce. This app is available on AppExchange, you just need to install it and make some administrator…

    AppExchange Apps, AppExchange Tools, Automation, Call Logs in Salesforce, Calling from Salesforce
    PRANAV Mar 30, 2018
    9,991  Views
    Salesforce Apex Trigger – Child to Parent Trigger using Map

    Salesforce Apex Trigger - Child to Parent Trigger using Map

    Blog in Others, Salesforce Apex

    Hello guys, In this blog, I am sharing the code of trigger it will update the account field on updation or insertion of Contact field.…

    Child Trigger, Maps in Salesforce, Parent Child Relationship, Parent Trigger, Salesforce Account
    Avnish Yadav Sep 24, 2018
    24,410  Views
    Marketing Cloud

    Saving Journey History in Salesforce Marketing Cloud

    Blog in Salesforce

    Salesforce Marketing Cloud allows you to set your contacts on a marketing journey with timed communications and logic-based actions. It also gives you the ability…

    Automation, Business Units, Campaigns, Contacts, Customer Journeys
    DB Jun 21, 2021
    10,728  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.