Automation Champion

Automating Salesforce One Click at a Time
Automation Champion
  • Home
  • About Me
    • Testimonials
    • Resources
  • Process Builder
  • Salesforce Flow
  • Pardot
  • Apex
  • Training Details
    • Salesforce Administrator
    • Salesforce Advanced Administrator
    • Platform App Builder
    • Lightning Flow
    • Pardot
    • Sales Cloud
    • Service Cloud
    • Community Cloud
    • Hands-on Excercises
  • My Books
  • Contact Me
  • Tag: Salesforce Public Group

    • Getting Started with Process Builder – Part 19 (Automatically Add New User to Public Group or Queue)

      Posted at 2:26 AM by Rakesh Gupta, on April 16, 2015

      Big Idea or Enduring Question:

      How do you automatically add new users to a Public Group or Queue? 

      Objectives:

      This blog post will help us to understand the following

      • Create automation associated with creating a new user
      • Automatically add a user to a specified Public Group or Queue
      • How to use flows action in Process Builder
      • What is MIXED DML error and how to avoid it

      Business Use case

      Warren Mason is working as a System administrator at Universal Containers (UC). His organization wants to develop an automation to auto add new users to Public Group Universal Container Users.

      Automation Champion Approach (I-do):

      In this article Getting Started with Process Builder – Part 24 (Automatically Add User to a Chatter Group), We had discussed a way to auto add new users to the Chatter group using clicks, not code. We also discussed a way to avoid MIXED DML error.

      Now let’s take it a step further and discuss a way to auto add new users to Queue or Public Group.  There are few solutions possible for the above business scenario. We will use Flow and Process Builder to solve the above business requirement.

      Before proceeding ahead, you have to understand Group and GroupMember objects. 

      1. Group: – This object represents the Queue and Public Group. They can contain individual users, other groups, the users in a particular role. By using the Type field, you can distinguish between Queue and Public Group. For Public Group (Use Type = Regular) and for Queue (Use Type = Queue).
      2. GroupMember: – Represents a User or Group that is a member of a public group.

      Before discussing the solution, let me show you a diagram of a Process Flow at a high level. Please spend a few minutes to go through the following Flow diagram and understand it.

      Let’s begin building this automation process.

      Guided Practice (We-do):

      There are 5 steps to solve Warren’s business requirement using Flow and Process Builder. We must: 

      1. Create a public group
      2. Find the public group Id
      3. Creating a custom label to store public group Id
      4. Lightning Flow Steps:
        1. Define flow properties for auto-launched flow
        2. Add a text variable to store user-id
        3. Add a create records element to add users to the public group
      5. Process Builder Steps:
        1. Define process properties
        2. Define evaluation criteria
        3. Define process criteria
        4. Set time for actions to execute
        5. Add action – flows 

      Step 1: Create a Public Group

      1. Click Setup.
      2. In the Quick Find box, type Public Group.
      3. Click on the Public Group button.
      4. Clicks on the New button. 
      5. Label the Group then press the tab key, the Group Name will auto-populate. 
      6. Click Save.

      Step 2: Find the Public Group Id for UC Internal Announcements 

      The next step is to find out the Id of the public group Universal Containers Users. One possible workaround is to use the Developer Console. 

      1. Click Setup | Developer Console 
      2. In the Query Editor, run the following SOQL query 
        1. Select id, name from group where (name=’Universal Container Users’ and Type = ‘Regular’)
      3. Make sure to copy the Id. 

      Step 3: Creating a Custom Label to Store Public Group Id

      1. Click Setup.
      2. In the Quick Find box, type Custom Labels.
      3. Select Custom Label then click on the New Custom Label button.
      4. Enter Short Description the Name will auto-populate. 
      5. Now enter the Universal Containers Users public group id in the Value.
      6. Click Save.

      Step 4.1: Lightning Flow – Define Flow Properties 

      1. Click Setup.
      2. In the Quick Find box, type Flows.
      3. Select Flows then click on the New Flow.
      4. Select the Autolaunched Flow (No Trigger) option and click on Next and configure the flow as follows: 
        1. How do you want to start building: Freeform
      5. Click Done.

      Step 4.2: Lightning Flow – Add  a Text Variable to Store User Id

      1. Under Toolbox, select Manager, then click New Resource to pass the store User Id.
      2. Input the following information: 
        1. Resource Type: Variable
        2. API Name: varTUserId
        3. Data Type: Text
        4. Default Value: {!$GlobalConstant.EmptyString}
        5. Check Available for Input
        6. Check Available for Output
      3. Click Done.

      Step 4.3: Lightning Flow – Create Records – Add users to the Public Group

      To add a new user to Public Group drag and drop a Record Create onto the flow designer and map the fields according to the below details. 

      1. Under Toolbox, select Elements. Drag and drop Create Records onto the canvas. 
      2. Input the following information:
        1. Enter Label the API Name will auto-populate.
        2. How Many Records to Create: One
        3. How to Set the Record Fields: Use separate resources, and literal values
        4. Object: Group Member
        5. Set Field Values for the Group Member
        6. Row 1:
          1. Field: GroupId
          2. Value: {!$Label.UC_Public_Group_Id}
        7. Click Add Row
        8. Row 2:
          1. Field: UserorGroupId
          2. Value: {!varTUserId}
      3. Click Done.

      In the end, Warren’s Flow will look like the following screenshot:

      Once everything looks good, perform the steps below: 

      1. Click Save.
      2. Enter Flow Label the API Name will auto-populate.
      3. Click Show Advanced.
      4. API Version for Running the Flow: 50
      5. Interview Label: Automatically Add New User to Public Group {!$Flow.CurrentDateTime}
      6. Click Save. 

      Almost there! Once everything looks good, click the Activate button.  

      Our next task is to create a Process on the User object to launch a Flow, only when a user is created.

      Step 5.1: Define Process Properties

      1. Click Setup.
      2. In the Quick Find box, type Process Builder.
      3. Select Process Builder, then click New.
      4. Name the Process and click the Tab button. The API Name will populate. 
      5. As a best practice, always input a description. 
      6. The process starts when A record changes.
      7. Click Save.

      Step 5.2: Define Evaluation Criteria

      1. Click on the Add Object node to begin selecting the evaluation criteria.
      2. Select the User object from the dropdown list.
      3. Start the process only when a record is created.
      4. Click Save.

      Step 5.3: Define Process Criteria

      1. Click the Add Criteria node to begin defining the process criteria.
      2. Name the criteria.
      3. The criteria should execute actions when the conditions are met.
      4. Set Conditions
        1. Row 1
          1. Field: User | IsActive
          2. Operator:  equal
          3. Type: Boolean
          4. Value: True
      5. Select All of the conditions are met (AND). 
      6. Click Save.

      Step 5.4: set time for actions to execute

      DML operations on certain sObjects referred to as setup objects (such as a User Object), along with, on the non-setup object (such as Accounts), in the same transaction, then, a Mixed DML error is thrown at a User.

      The Mixed DML error is generated – when a User performs DML actions on Setup and non-Setup Objects in the same transaction -because some sObjects affect the user’s access to records in the org. Therefore, a user must insert or update these types of sObjects in different transactions to prevent operations from happening with incorrect access-level permissions. For example, a user cannot update an account, and a user role, in a single transaction. However, deleting a DML operation has no restrictions (reference Salesforce help).

      We are adding time delays to avoid MIXED DML Errors.

      1. Below Scheduled Actions, click Set Schedule.
      2. Set Field Values:
        1. Row 1:
          1. 0
          2. Hours
          3. After
          4. CreatedDate
      3. Click Save.

      Step 5.5: Add Action – Flows

      1. Below 0 Hours After CreatedDate Scheduled Actions, click Add Action.
      2. For Action Type, select Flows. 
      3. Name the action.
      4. Select Flow – Automatically Add New User to Public Group.
        1. Set Flow variables: 
          1. Row 1
            1. Field: varTUserId
            2. Type: Field Reference
            3. Value: User | Id
      5. Click Save.

      In the end, Warren’s Process will look like the following screenshot:

      Almost there! Once everything looks good, click the Activate button. 

      Proof of Concept

      Now onwards, when a user account is created, Process Builder will automatically trigger and launch the Flow. It will then add the user to a public group (Universal Container Users) post after a few minutes. Let’s test it out.

      1. Now create a new user via the UI
        Create new user
      2. Once the user is created, they are automatically added to the public group Universal Container Users within a few seconds, as shown in the following screenshot:

      Formative Assessment:

      I want to hear from you!  

      What is one thing you learned from this post? How do you envision applying this new knowledge in the real world? 

      Let me know by Tweeting me at @automationchamp, or find me on LinkedIn.

      Have feedback, suggestions for posts, or need more information about Salesforce online training offered by me? Say hello, and leave a message!

      Posted in Process Builder, Salesforce Flow, User Management | 12 Comments | Tagged Add Criteria Proces builder, Add Member into public group, Add Member into queue, Add new user to Chatter Group, ADM 201, adm 201 certification, adm 201 salesforce, admin release exam, Advance flow, Auto add new user to public Group, Auto add new user to public groups, Auto add new user to queue, Auto add new user to queues, Automatically add individuals to public Group upon provisioning new user, Automatically add individuals to queue upon provisioning new user to queue, Automatically Add New User to public group, Automatically Add New User to public Group Salesforce, Automatically Add New User to queue Salesforce, Cloud Flow Designer Workbook, Con 201, Create record through flow, dev 401, DEV401, developer release exam, Enable Process Builder, Evaluate the rule when a record is created, flow, Flow and PB examples, Flow and Prcoess Builder examples, FLow and Process builder example, Flow Example, Flow examples, Getting started with Process Builder, Group object in Salesforce, GroupMember object in Salesforce, How to activate Process builder, how to use Process builder, Launch a Flow, Launch a Flow from Process builder, Lightning App, Lightning Process builder, Mixed Dml, MIxed DML Error, Mixed DML Flow, Mixed DML Solution, New Flow, New User Creation, PB, Process Builder, Process Builder example, Process Builder examples, Process Builder Salesforce, Process builder use case, Public group, Queue, Quick Action in Process Builder, Record Create, salesforce, salesforce certified developer exam, Salesforce maintenance exam, Salesforce Public Group, Salesforce release exam, Salesforce release exam dates, Salesforce release exams, Spring15 process builder, Spring15 Process builder enhancement, Update Records, Visual workflow, Visual workFlow examples, Visual Workflow Implementation Guide, workflow rule
    • Search

    • Upcoming Trainings

      Salesforce Administrator Certification
      Salesforce Advanced Administrator Certification
      Salesforce Platform App Builder Certification
      Lightning Flow & Process Builder
      Advanced Lightning Flow
      Pardot Specialist & Consultant Certification
      Sales Cloud Consultant Certification
      Service Cloud Consultant Certification
      Community Cloud Consultant Certification
    • Sponsor #1

    • Sponsor #2

    • Sponsor #3

    • Sponsor #4

    • Order Now!

    • Buy My Book

    • Buy My Book

    • Recent Posts

      • Getting Started with Salesforce Flow – Part 58 (Customize Previous, Next, Finish, and Pause Button Label for Screen Flow!)
      • Streamline Data Collection with Salesforce-Connected Forms
      • Getting Started with Salesforce Flow – Part 56 (Merge Chatter Topics with the Help of Salesforce Flow)
      • Getting Started with Salesforce Flow – Part 57 (Adding Validation to Flow Screen Components)
      • Getting Started with Salesforce Flow – Part 55 (Add or Remove Followers to a Record with the Help of Salesforce Flow)
    • Salesforce ID Converter Build on Lightning Flow

      Converting 15 digit ID to 18 digit Salesforce ID
    • Blog Archives

    • Categories

  • Information

    • About Me
    • Affiliate Disclaimer
    • Contact Me
    • Privacy Policy
  • Top Posts

    • Learning Flow
    • Learning Process Builder
    • Getting Started with Salesforce Flow – Part 27 (Want to Send an HTML Email from Salesforce Flow? Oh, yes! It can be done!)
    • Salesforce Spring’21 Release Quick Summary
    • Getting Started with Salesforce Flow – Part 11 (Count Number of records in a Record Collection Variable)
    • Getting Started with Salesforce Flow – Part 58 (Customize Previous, Next, Finish, and Pause Button Label for Screen Flow!)
    • Learning Apex
    • Getting Started with Salesforce Flow – Part 42 (Running a Flow in System Mode)
    • Getting Started with Salesforce Flow – Part 28 (Have a File Upload Component and Other Details on a Single Screen? Really? Wow!)
    • Getting Started with Salesforce Flow – Part 24 (Automatically Assign Permission Sets to New User)
  • Social Media

    • View Automationchampion’s profile on Facebook
    • View Automationchamp’s profile on Twitter
    • View Rakeshistom’s profile on GitHub