• Home
  • Articles
    • All Articles
    • Blogs
    • Videos
    • Infographics
  • Consultants
    • Salesforce Product Expertise
      • Top Salesforce Consultants
      • Marketing Cloud Consultants
      • Service Cloud Consultants
      • Experience Cloud Consultants
      • Analytics Cloud Consultants
    • Salesforce Industry Expertise
      • Non-Profit Cloud Consultants
      • Financial Service Cloud Consultants
      • Health Cloud Consultants
      • Commerce Cloud Consultants
      • Manufacturing Cloud Consultants
  • Jobs
  • Marketplace
  • Stories
  • Advertise With Us
  • Top Bloggers 2022
  • Quizzes
  • Discussions
  • Groups
    Sign in Sign up
    • Home
    • Articles
      • All Articles
      • Blogs
      • Videos
      • Infographics
    • Consultants
      • Salesforce Product Expertise
        • Top Salesforce Consultants
        • Marketing Cloud Consultants
        • Service Cloud Consultants
        • Experience Cloud Consultants
        • Analytics Cloud Consultants
      • Salesforce Industry Expertise
        • Non-Profit Cloud Consultants
        • Financial Service Cloud Consultants
        • Health Cloud Consultants
        • Commerce Cloud Consultants
        • Manufacturing Cloud Consultants
    • Jobs
    • Marketplace
    • Stories
    • Advertise With Us
    • Top Bloggers 2022
    • Quizzes
    • Discussions
    • Groups

    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 4 years, 4 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

    Reply

    Subscribe

    airslate

    SALESFORCE PRODUCT EXPERTISE

    • Top Salesforce Consultants
    • Top Salesforce Experience Cloud Consultants
    • Top Salesforce Analytics Cloud Consultants
    • Top Salesforce Service Cloud Consultants
    • Top Salesforce Marketing Cloud Consultants

    SALESFORCE INDUSTRY EXPERTISE

    • Top Salesforce Consultants
    • Top Salesforce Manufacturing Cloud Consultants
    • Top Salesforce Non-Profit Cloud Consultants
    • Top Salesforce Health Cloud Consultants
    • Top Salesforce Financial Service Cloud Consultants
    • Top Salesforce Commerce Cloud Consultants

    Popular Salesforce Blogs

    Salesforce Security Model

    Salesforce Security Model - An Overview

    Blog in Salesforce Security

    What is Salesforce Data Security? Presently Salesforce offers a thorough and flexible data security model for tying down data at totally various levels to give…

    Apps, Associate Admin, Business Profile, Campaigns Object, Certifiable Business Issues
    Ratnesh Feb 11, 2021
    3,378  Views
    Business Hours And Holidays In Salesforce

    Business Hours And Holidays In Salesforce

    Blog in Salesforce

    Business Hours Business hours define the hours your team is available to support your customers and Holidays allow you to select when your customer support…

    Admin, Business Hours, Company Settings, Configurations, Customer Support
    Anshu Nov 29, 2021
    8,524  Views
    Switching From Classic to Salesforce Lightning

    Points to Remember for Switching Your Salesforce Org From Classic to Lightning

    Blog in Others

    Hello Salesforce Lovers, This blog helps you in analysing what are the things you need to remember for switching your Salesforce org from Classic to…

    PRANAV Mar 26, 2018
    2,590  Views
    Footer Forcetalks logo

    [email protected]

    Forcetalks Android App
    Forcetalks IOS App

    Quick Links

    Advertise with Us

    Salesforce® Articles

    Dreamforce 2022

    Top Salesforce® Bloggers 2021

    Tips to choose Best Salesforce® Consulting Company

    Get Listed

    Company

    Contact Us

    About Us

    Privacy Policy

    Terms & Conditions

    Submissions

    Write a Blog

    Start a New Discussion

    Post a Video

    Post an Infographic

    © 2023 - 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®.

    Forum Description

    Report

    There was a problem reporting this post.

    Harassment or bullying behavior
    Harassment or bullying behavior
    Contains mature or sensitive content
    Contains misleading or false information
    Mobile App Reported Contents
    Contains abusive or derogatory content
    Contains spam, fake content or potential malware

    Block Member?

    Please confirm you want to block this member.

    You will no longer be able to:

    • See blocked member's posts
    • Mention this member in posts
    • Invite this member to groups
    • Message this member
    • Add this member as a connection

    Please note: This action will also remove this member from your connections and send a report to the site admin. Please allow a few minutes for this process to complete.

    Report

    You have already reported this .
    Clear Clear All
    We use cookies to enhance your browsing experience. Please see our privacy policy if you'd like more information on our use of cookies.