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 › Is there any way to can create the profile in the salesforce in apex test class. How?

    Tagged: Profile, Salesforce Apex, Test Class, User Profile

    • Salesforce® Discussions

      Is there any way to can create the profile in the salesforce in apex test class. How?

      Posted by Mohit on July 26, 2016 at 4:38 PM

      Hi all,

      Is there any way to can create the profile in the salesforce in apex test class. How?

      Please give suggestions.

      PRANAV replied 7 years, 10 months ago 3 Members · 2 Replies
      • Profile
      • Salesforce Apex
      • Test Class
      • User Profile
    • 2 Replies
    • Sourabh

      Member
      July 27, 2016 at 2:06 PM

      Hi Mohit,

      You cannot create profiles in apex code, either through tests or otherwise, this is presumably a security limitation.

      Thanks

    • PRANAV

      Member
      January 19, 2018 at 11:26 AM

      Hi Mohit,

      You can create an user but you need to query the required profile according to the requirement..! As you cannot create a profile.

      Profile profileId = [SELECT Id FROM Profile WHERE Name = 'Standard User' LIMIT 1];
      User usr = new User(LastName = 'Bhardwaj',
      FirstName='Pranav',
      Alias = 'pbhar',
      Email = 'Pranav.Bhardwaj@asdf.com',
      Username = 'Pranav.Bhardwaj@asdf.com',
      ProfileId = profileId.id,
      TimeZoneSidKey = 'GMT',
      LanguageLocaleKey = 'en_US',
      EmailEncodingKey = 'UTF-8',
      LocaleSidKey = 'en_US'
      );

      You can use the above code snippet for your test class. This may helps you to cover your apex class.

    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 Lightning map

    Salesforce Lightning:map - Show Locations on Google Map

    Blog in Lightning, Salesforce

    In the Salesforce winter 19 release, Salesforce introduced an awesome feature called lightning:map component that shows the Google maps on lightning experience but this component…

    Descriptive Information, Geocoding Information, google, Google Map, Google Map API
    Shweta Sep 4, 2020
    21,683  Views

    Salesforce Predictions 2020: What does the Future Hold for Salesforce?

    Blog in Others

    Salesforce, the market leader in CRM, has created a storm in the world of sales and marketing of products and services catering to a diverse…

    Einstein Analytics, Financial Services Cloud, Salesforce Aquisitions, Salesforce Consulting Companies, Salesforce CRM
    Algoworks Jan 2, 2020
    5,850  Views
    All You Need to Know About Service Console in Salesforce

    All You Need to Know About Service Console in Salesforce

    Blog in Salesforce

    Salesforce is a popular cloud-based Customer Relationship Management (CRM) platform that provides businesses with a variety of tools for managing their customer interactions. The Service…

    Better Collaboration, Case Management, Chatter, Collaboration Tools, CRM
    NAVDITA DAHIYA Apr 26, 2023
    2,545  Views

    Popular Salesforce Videos

    How to Nurture Leads in Salesforce Account Engagement? | Forms

    How to Nurture Leads in Salesforce Account Engagement? | Forms

    Video in Salesforce Products

    Discover how Salesforce Account Engagement (also known as Pardot) helps you create and embed personalized forms, enhancing the lead nurturing experience. To show its capabilities,…

    Salesforce Forms, Salesforce Admin, Customer Engagement, Salesforce Video, Salesforce Learning
    ENWAY Nov 16, 2023
    1,070  Views
    Salesforce Marketing Cloud Tutorial | Online Training

    Salesforce Marketing Cloud Tutorial | Online Training

    Video in Marketing, Salesforce Cloud Platform

    Salesforce Marketing Cloud (SFMC) is Salesforce’s platform (or “Cloud”) in the area of marketing automation and customer engagement. It is a SaaS platform made up…

    Salesforce Tutorial, salesforce platform, Marketing Automation, Salesforce Marketing Cloud, Customer Engagement
    Rupal Kakkar Apr 9, 2021
    3,599  Views
    How to Get Experience as a Fresher in Salesforce World? | The Shrey Sharma Show

    How to Get Experience as a Fresher in Salesforce World? | The Shrey Sharma Show

    Video in Salesforce Stories

    Want to start your career in the Salesforce industry? Watch this video by Shrey and learn how you can get experience as a Fresher in…

    salesforce knowledge, Salesforce Industry, Salesforce Career, Salesforce Learning, Salesforce Job
    Jogender Sep 23, 2021
    1,481  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.