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

    New Salesforce Interface: The Case for Lightning Migration from Classic

    Blog in Salesforce

    As we approach the end of the current year, it’s a great opportunity for businesses to evaluate their existing IT infrastructure and gear up for…

    Competitive Advantage, Cost Saving, CRM Attributes, CRM Technology, Customer Satisfaction
    Carol Dec 29, 2023
    1,678  Views

    FlexDeploy Loves Salesforce: Source Control Your Salesforce Changes

    Blog in Salesforce integration

    FlexDeploy is an Enterprise DevOps platform with fully integrated support for Salesforce apps, metadata customizations, integrations and more. This is the second article in a…

    Blueprints, Change Management Tools, Client ID, Cloud Integration, Communication Tools
    Flexagon Dec 16, 2021
    2,403  Views
    History of CRM

    What is The History of CRM and How is it Important in Today's Day and Age? | Salesforce

    Blog in Others, Salesforce

    Customers are the most important asset to any business no matter what industry you belong to, what your focus is, or what kind of products…

    Artificial Intelligence, Blockchain, Business, Business Intelligence Services, Business Needs
    Apphienz Mar 10, 2021
    2,239  Views

    Popular Salesforce Videos

    How To Create Workflow Rules In Salesforce | Salesforce Workflow Rules

    How To Create Workflow Rules In Salesforce | Salesforce Workflow Rules

    Video in Salesforce Training

    This video walks through the steps to create a Workflow Rule within the Process Automation section of Lightning Settings in Salesforce. Get answers to the…

    Salesforce Training, Salesforce Tutorial, Salesforce Lightning, Process Automation, salesforce
    Algoworks Sep 16, 2021
    1,572  Views
    Introduction to Salesforce CMS

    Introduction to Salesforce CMS

    Video in Salesforce Stories

    Salesforce CMS is a hybrid content management system, where you can curate and share content, manage multiple language versions of your content, and control who creates…

    Salesforce Training, Salesforce Tutorial, salesforce, Salesforce Video, Salesforce Learning
    Jogender Feb 14, 2022
    2,540  Views
    Level Up Your Processes With Google API and Salesforce Integration

    Level Up Your Processes With Google API and Salesforce Integration

    Video in Salesforce Integration

    Complex processes often span multiple systems. In this session, we'll cover how to integrate Google APIs into your Salesforce org with an API library in…

    Salesforce Apex, Salesforce Sales Cloud, Salesforce Integration, Apex APIs, Sales Cloud Consultant
    Nauman Mar 7, 2018
    2,085  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.