Toggle Side Panel

  • Blogs
  • 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
  • Contact Us
  • Discussions
More options
    Sign in Sign up
    • Blogs
    • 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
    • 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 8 years, 9 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

    • [adinserter block='9']
    • 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

    Popular Salesforce Blogs

    Value of Salesforce in Small and Medium Business

    Blog in Others

    Speed is the quintessence of the business world. That is valid for almost every part of our business, yet it's particularly valid for innovation and…

    Business Operations, Business Success, Community Cloud, Dreamforce, Marketing Cloud
    Christi Mar 6, 2018
    4,050  Views
    Salesforce Partner Learning Camp

    Salesforce Partner Learning Camp: A Trailhead for Partners?

    Blog in Salesforce, Salesforce Ecosystem

    Created exclusively for Salesforce partners, Salesforce Partner Learning Camp (PLC) is the primary educational resource for building service capabilities to meet customer demands. After Salesforce…

    B2B and B2C Space, Certification Vouchers, Consulting Partners, CPQ, Credential Tracker
    Algoworks May 13, 2021
    3,922  Views

    Top 8 Things to Consider While Selecting Salesforce CPQ Consulting Partner

    Blog in Salesforce

    Salesforce CRM has been a revelation when it comes to elevating the productivity of the company. Starting from managing the Sales Funnel to getting the…

    Business, Case Studies, Companies, Company, Configuration
    Stella George May 4, 2021
    4,903  Views

    Popular Salesforce Videos

    Work.com – Release Readiness LIVE, Summer '20 | Salesforce

    Work.com – Release Readiness LIVE, Summer '20 | Salesforce

    Video in Salesforce Stories, Salesforce Products

    Work.com is an online set of applications, resources, and content designed to help the entire workplace get back to business after the Covid-19 crisis. This…

    Workdotcom, Summer 20, COVID-19, Summer '20 Release, Salesforce Release
    Pooja Aug 14, 2020
    1,566  Views
    Skill Based Routing with Apex/Flows in Salesforce

    Skill Based Routing with Apex/Flows in Salesforce

    Video in Salesforce Apex

    This video is the sequel to the omnichannel Salesforce tutorial (LINK) In this video, we will cover: 1. What is Skill-based routing 2. Why is…

    Salesforce Training, Salesforce Tutorial, Apex Class, Salesforce Video, Salesforce Learning
    Pooja Oct 7, 2021
    3,818  Views
    Rise & Shine with The Salesforce Women's Entrepreneur Group - May Series

    Rise & Shine with The Salesforce Women's Entrepreneur Group - May Series

    Video in Salesforce Stories

    The Salesforce Women’s Entrepreneur Group invites you to our first quarterly event of the year, Rise & Shine - Celebrating Women’s History Month. We are…

    Salesforce Training, Salesforce Ecosystem, Salesforce Video, Salesforce Learning, Businesses
    Rupal Kakkar May 18, 2021
    2,016  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®.

    We use cookies to enhance your browsing experience. Please see our privacy policy if you'd like more information on our use of cookies.