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

    Implementing WebMerge for Salesforce Using Apex

    Implementing WebMerge for Salesforce Using Apex

    Blog in Salesforce Apex, Salesforce Implementation

    Webmerge is used to Customize and Automate Your Document Generation. It is an online service that self-operating your document creation process. It helps to create…

    Document generation in salesforce, Mass doc generation, Multiple records processed using webmerge, Salesforce Apex, Salesforce Apex Code
    Adarsh Mar 23, 2018
    10,162  Views
    Salesforce Data integrity and it's maintenance

    Salesforce Data Integrity & How to Maintain it?

    Blog in Others, Salesforce Data integration

    This blog on Salesforce data integrity features a brief intro to the contacts and accounts information inside the Salesforce and how do you establish a…

    Cloud Based CRM, maintaining data integrity, Salesforce, Salesforce Data Integrity, tags
    William Feb 26, 2019
    14,336  Views

    Salesforce Commerce Cloud: Maximizing Revenue

    Blog in Salesforce Cloud Platform

    In the ever-evolving world of e-commerce, staying ahead of the competition and delivering exceptional customer experiences is critical. With the advent of Salesforce Commerce Cloud,…

    Applications, Australia, Automate Marketing Campaigns, Benefits, Boost Conversion Rates
    Kizzy Consulting Aug 4, 2023
    1,519  Views

    Popular Salesforce Videos

    QuickBooks Salesforce Connector | Setup & Configuration

    QuickBooks Salesforce Connector | Setup & Configuration

    Video in Salesforce Integration, Salesforce Training

    QuickBooks Salesforce Connector: https://eshopsync.com/quickbooks/​ is taking the cloud-based platforms to the new altitudes. Now dealing with QuickBooks unlimited data is much easier than ever before.…

    Salesforce Training, Salesforce Tutorial, Salesforce Video, Salesforce Learning, Salesforce connector
    Deepika Feb 17, 2021
    2,324  Views
    Replicate Salesforce Data in Real-Time with Change Data Capture

    Replicate Salesforce Data in Real-Time with Change Data Capture

    Video in Salesforce Integration

    In this video, we will see how to replicate Salesforce data Migrate your batch processing, scheduled ETL, and nightly workloads to event-driven, real-time integrations using…

    Salesforce Training, Salesforce Tutorial, salesforce, Data Integration, Salesforce Video
    John Mar 12, 2021
    4,409  Views
    Exploring Technology Choices For Salesforce Integration

    Exploring Technology Choices For Salesforce Integration

    Video in Others

    Are you struggling to find the perfect technology to integrate Salesforce into your business processes? Integrating Salesforce into your business processes can offer significant advantages,…

    salesforce, Salesforce Video, Salesforce VIdeos, salesforceintegration, salesforcepartner
    Cyntexa Oct 23, 2023
    992  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.