Getting Started with Process Builder – Part 20 (Add Chatter Followers to Record)

Posted on Updated on

FollowerFew months back, I had written an article Add/Remove follower to record with Visual Workflow to discuss a way through which we can add or remove Chatter followers to account record. As you all know Flow runs in system mode, it means the Flow we had developed will only work for System administrators and users with the Modify All Users permission. There are few business scenarios where business wants some workaround so that Flow will work for all the users. First of all I want to say thanks to Adam Plocki for asking such a great question on Success Community. Let’s start with a business use case

Business Use case :- Warren Mason is working as System administrator in Universal Container. He received a requirement to develop an application, that will allow users (For those, who have edit permission on account object) to add Chatter followers to record. 

 Solution of above business requirement

There are few solutions possible for the above business scenario. We will use Flow and Process Builder (because it runs in system mode) to solve the above business requirement. The advantage of using Flow with Process builder is, you don’t have to assign Force.com Flow User feature license to the users. Before proceeding ahead, you have to understand EntitySubscription object in Salesforce. It’s Represents a subscription for a user following a record or another user. User can subscribe to a record or to another user.

Field Name Details
ParentId ID of the record or user which the user is following
SubscriberId ID of the User who is following the record or user

Follow the below instructions to create a Flow and Process Builder to solve the above business requirement

1. First of all create a Custom field Add Follower (Data Type :- Lookup (User)) on the Account object. We will use this field in the Flow and Process Builder.
2. To create a Flow, click on Name | Setup | App Setup | Create | Workflows & Approvals | Flows
3. Click on New Flow, it will open Flow canvas for you. Now we have to create a two variables. First create a Text variable AccountId  to store the accountId (we will pass the account Id through Process Builder) as shown in the below screenshot

Text Variables to store account Id
Text Variables to store account Id

Second Variable FollowerID is used to store the user Id, whom you want to add as a Chatter follower to record.

Text Variables to store follower Id
Text Variables to store follower Id

4. To add a Chatter follower to record, drag-and-drop a Record Create ( Give the name Auto add follower to record) onto the window and map the fields according to below details

  • Select Object EntitySubscription
  • Enter Assignment ParentId= {!AccountId} and SubscriberId= {!FollowerID}, as shown in the below screenshot
Add Follower to record
Add Follower to record

5. Finally your Flow will look like the following screenshot

Add Chatter Followers to Record6. Save your flow with name Add Chatter follower to record PB and close the canvas. Don’t forget to Activate the Flow.

Launch a Flow from Process Builder

Our next task is to create a workflow on the Account object to launch a Flow. To create a workflow on the Account object follow the below instructions

1. Click on Name | Setup | App Setup | Create | Workflows & Approvals | Process Builder  and click on the New button, Enter Name, API Name and then click on the Save button

Define Process Properties
Define Process Properties

2. The next step is to add entry criteria. For this click on Add Object, select Account object and for the entry criteria, Select when a record is created or edited, as shown in the below screenshot, once you are done click on the Save button

Evaluation Criteria
Evaluation Criteria

3. The next task is to add Process Criteria, To do this click on Add Criteria, enter Name, Type of action and set filter conditions  (In this case set [Account].Add_Follower__c Is Changed True) and click on the Save button, as shown in the following screenshot

Process Criteria
Process Criteria

4. The next step is to add an Immediate action to Process. Click on Add Action (Under Immediate actions), Select the type of action to create (In our case Flows) , and then fill out the fields to define the action, as shown in the following screenshot

Add action – Flows
Add action – Flows

5. Once you are done, click on the Save button, it will redirect you to Process canvas. Finally the Process will look like the following screenshot

Add Chatter followers to recordDon’t forget to active the Process by clicking on the Activate button.

It’s time to test this App

1) Now LoggedIn through a business user account. In this demo I am going to use Demo User account (Profile assigned:- Standard User, Force.com Flow User feature license is not assigned to this user  ).

Demo account
Demo account

2) The next step is to edit the record and populate the Add Follower field as shown in the following screenshot

Final result
Final result

Finally checkout the Follower section available on the record detail page.

Note :-  I will suggest you to implement this first on your developer org test it and then move it to Production.

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

Posted on Updated on

Public GroupIn this article Automatically Add New User to Chatter Group, We had discussed a way to auto add new users to Chatter group using click not code. We also discussed a way to avoid MIXED DML error. In this article we are going to discuss a way to auto add new users to Queue or Public Group. Let’s start with a business use case

Business Use case :- Warren Mason is working as System administrator in Universal Container. His organization wants to develop an application to auto add new users to Public Group “Universal Container Users“.

Solution of above business requirement

There are few solutions possible for the above business scenario. We will use Flow, Workflow Rule 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 Queue and Public Group both. Groups are sets of users. They can contain individual users, other groups, the users in a particular role. By using 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.

Follow the below instructions to create a Flow, Workflow Rule and Process Builder to solve the above business requirement

1. Create a Custom field OneTimeActivity (Data Type :- Check-box, Default Value:- False) on the User object. We will use this in Process Builder.
2. To create a Flow, click on Name | Setup | App Setup | Create | Workflows & Approvals | Flows
3. Click on New Flow, it will open Flow canvas for you. Now we have to create a few variables. First create a Text variable VarT_UserId  to store the user Id (we will pass new user Id through Process Builder) as shown in the below screenshot

Text Variables to store user Id
Text Variables to store user Id

Second Variable VarT_PublicGroupId is used to store public Group Id. In this scenario public group Universal Container Users Id, as shown in the following screenshot

Text Variables to store Public group Id
Text Variables to store Public group Id

4. To add a new user to Public Group, drag and drop a Record Create ( Give the name Add user to Public Group) onto the window and map the fields according to below details

  • Select Object GroupMember
  • Enter Assignment GroupId= {!VarT_PublicGroupId} and UserOrGroupId= {!VarT_UserId}, as shown in the below screenshot
Add user to Public group
Add user to Public group

5. Finally your Flow will look like the following screenshot

Add user to Public group6. Save your flow with name Automatically add new user to public group and close the canvas. Don’t forget to Activate the Flow.

Launch a Flow from Process Builder

Our next task is to create a workflow on User object to update the OneTimeActivity field to True then we will create a Process on User object to launch a Flow. To create a workflow on the User object follow the below instructions

1. Click on Name | Setup | App Setup | Create | Workflows & Approvals | New Rule, then select object User from the drop-down
2. Enter Name, for Evaluate the rule when a record is select Created, For Rule Criteria select is Active To True, as shown in the below screenshot 

Workflow rule on User creation
Workflow rule on User creation

3. Now Add a time trigger to  to update OneTimeActivity To True (Custom field – Checkbox ) after 0 hours of record Created date. To do this click on Add Time Trigger button and Set the length after how many days/hours workflow will fire  i.e.  in hours and days, I’ve selected 0 hours after the Created Date. Now add one field update action for time dependent workflow and update the OneTimeActivity to True. You can take help from the following screenshot

Workflow field update
Workflow field update

4. Save the workflow rule and activate it.
5. Our next task is to create a Process on User object to launch a Flow. To create a Process click on Name | Setup | App Setup | Create | Workflows & Approvals | Process Builder  and click on the New button, Enter Name, API Name and then click on the Save button

Define Process Properties
Define Process Properties

6. Click on Add Object, select User object and for the entry criteria, Select when a record is created or edited, as shown in the below screenshot and once you are done click on the Save button

Evaluation Criteria
Evaluation Criteria

7. The next task is to add Process Criteria, To do this click on Add Criteria, enter Name, Type of action and set filter conditions  (In this case set [User].OneTimeActivity__c Equals True) and click on the Save button, as shown in the following screenshot

Process Criteria
Process Criteria

8. The next step is to add an Immediate action to Process. Click on Add Action (Under Immediate actions), Select the type of action to create (In our case Flows) , and then fill out the fields to define the action, as shown in the following screenshot

Add action – Flows
Add action – Flows

9. Final Step is to add one more Immediate action to update OneTimeActivity to False, We will use update Records action in the Process, Please refer to the following screenshot for more details

Add action – Update Records
Add action – Update Records

10. Once you are done, click on the Save button, it will redirect you to Process canvas. Finally the Process will look like the following screenshot

Add user to public group (2)

Don’t forget to active the Process by clicking on the Activate button.

It’s time to test this App

To test this application follow the below instructions

1) Navigate to Name | Setup | Administration Setup | Manage Users | Users
2) Create a New User

Create new user
Create new user

3) Now navigate to the Public Group (Universal Container Users) and check new user under View all users list

Final Outcome
Final Outcome

Note :-  I will suggest you to implement this first on your developer org test it and then move it to Production.

Getting Started with Process Builder – Part 18 (Use a Quick Action)

Posted on Updated on

Quick action

Publisher Actions let you have Quick actions to be taken from a Chatter or Home page or Record detail pages. You can create an action like create records, update records and log calls directly in the feed. There are two ways to create actions in Salesforce, those are followings

  • Object Specific Actions
  • Global Actions

In this article I am going to discuss how to use a quick action from a Process. Let’s start with a business use case

Business Use case:-  Warren Mason is working as System administrator in Universal Container. His organization wants to auto creates a private Chatter group, whenever a campaign gets created. For Chatter group name they want to use campaign name.  

Solution of above business requirement

There are few solutions possible for the above business scenario. We will use Global Action (NewGroup) and Process Builder to solve the above business requirement. You can also use publisher action with process builder to create, update records or Log a Call purpose. The benefits of using Global or Object specific action with Process builder over Create a Record or Update Records action are following

Global or Object specific action
Create a Record or Update Records
It allows you to set the Record Type without hard code the ID
Currently you have to hard code the record ID
It allows you to use Dynamic Dates When Inserting or Updating a record
Currently it’s not possible with Process Builder Create a Record or Update Records action (Workaround is to use Custom Formula field)
It allows you to create Chatter Group or Notes
Currently Process Builder doesn’t support Group, Note object
It allows you to use Formulas in Field Updates
Currently this is not possible with Process Builder (Workaround is to use Custom Formula field)

Follow the below instructions to create a Process  for the above business requirement
1. Click on Name | Setup | App Setup | Create | Workflows & Approvals | Process Builder, it will redirect you to the Process management page
2. Click on the New button, Enter Name, API Name and click on the Save button, as shown in the following screenshot

Define Process Properties
Define Process Properties

3. Click on Add Object, select Campaign object and for the entry criteria, Select only when a record is created, as shown in the below screenshot and also click on the Save button

Evaluation Criteria
Evaluation Criteria

4. The next task is to add Process Criteria, To do this click on Add Criteria, enter Name, Type of action and set filter conditions  (In this case set [Campaign].Name Is null False) and click on the Save button, as shown in the following screenshot

Process Criteria
Process Criteria

5. The next step is to add an Immediate action to Process. Click on Add Action (Under Immediate actions), Select the type of action to create (In our case Quick Actions), and then fill out the fields to define the action, as shown in the following screenshot

Add action – Quick Actions
Add action – Quick Actions

6. Once you are done, click on the Save button, it will redirect you to Process canvas. Finally the Process will look like the following screenshot

 Auto create Chatter Group on Campaign creation

Don’t forget to active the Process by clicking on the Activate button

It’s time to test this App

Now onwards if a business user creates a campaign, then Process Builder will automatically trigger and create a Chatter group.

Final Outcome
Final Outcome

Note:-  I will suggest you to implement this first on your developer org test it and then move it to Production.

Getting Started with Process Builder – Part 17 (Auto Delete System Generated Chatter Post)

Posted on Updated on

Delete Post

In Salesforce Chatter is a great way to boost collaboration in your organization. User can Post Status, links, Files and comments on others post . Many time I found on discussion board people are looking for a way to Delete System generated Chatter post. In this article I am going to discuss how to auto delete system generated Chatter post. Let’s start with a business use case

Business Use case:-  Warren Mason is working as System administrator in Universal Container. When we convert the Lead automatic chatter post appears on Account feed i.e. UserName converted a lead to this account, as shown in the following screenshot

Auto generated chatter post
Auto generated chatter post

He wants to auto delete this post upon lead conversion.

Solution of above business requirement

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 you have to understand the Feed table in Salesforce. All objects have a default related “Feed” object. All Feed objects for custom objects are named as CustomObject__Feed, where CustomObject__c is the name of the related custom object. All Feed objects for standard objects are named as LeadFeed, where Lead is the name of the related standard object. Now you have to understand below mentioned objects in Salesforce

A) AccountFeed:- This object represents a single feed item in the feed displayed on the detail page for a lead record.

First of all we will use Flow to delete system generated Chatter post. To launch the Flow whenever Lead gets converted we will use Process Builder. This article will help you to understand how to auto delete system generated chatter post by using Flow and Process Builder. Follow the below instructions to create a Flow for the above business requirement

1. First of all create few fields as Shown in the following table

Field Name Object
Data Type
Default Value
Lead Conversion
Account Checkbox
Unchecked
Lead Conversion Lead Checkbox Checked

We will use above fields in the Process Criteria.

2. Click on Setup | Build | Customize | Leads | Fields, navigate to Lead Custom Fields & Relationships related list and click on the Map Lead Fields button. It will redirect you to another page where you can map each of your organization’s lead custom fields to one of your custom account, contact, or opportunity fields. These mappings will be used when you convert leads. Map both the fields as shown in the following screenshot

Map Lead Fields
Map Lead Fields

3. Click on Setup | Build | Create | Workflows & Approvals | Flows
4. Click on New Flow, it will open the Flow Canvas for you. Create two text variables VarT_ParentId (To pass account Id) as Shown in the following screenshot

Text Variable
Text Variable

5. The next step is to delete system generated post upon lead conversion. For this drag-and-drop Record Delete Element (Give the name Delete lead conversion Chatter post) on the Flow Canvas and fill the details as shown in the following screenshot

Delete Record - delete system generated chatter post
Delete Record – delete system generated chatter post

Once you are done click on OK. Finally your Flow will look like the following screenshot, click on icon that mark in red to set as start point

Delete system generated post

6. Save your flow with name Delete system generated post and close the canvas. Don’t forget to Activate the Flow.

Launch a Flow from Process Builder

Our next task is to create a Process on Account object to launch a Flow. To create a Process on the Account object follow the below instructions

1. Click on Name | Setup | App Setup | Create | Workflows & Approvals | Process Builder  and click on the New button, Enter Name, API Name and click on the Save button
2. Click on Add Object, select Account object and for the entry criteria, Select when a record is created, as shown in the below screenshot and also click on the Save button

Evaluation Criteria
Evaluation Criteria

3. The next task is to add Process Criteria, To do this click on Add Criteria, enter Name, Type of action and set filter conditions  (In this case set [Account].Lead_Conversion__c Equals True) and click on the Save button, as shown in the following screenshot

Process Criteria
Process Criteria

4. The next task is to set the time for schedule action. For this click on Set Schedule available under Scheduled actions. Set time for scheduled actions as shown in the following screenshot

Time for Scheduled action
Time for Scheduled action

5. Now we have to add a Time-based action into the Process to Launch a Flow. For this we will use Flow action, Use Field Picker to select the field AcountID. Please refer to the following screenshot for more details

Add action – Flows
Add action – Flows

6. Once you are done, click on the Save button, it will redirect you to Process canvas. Finally the Process will look like the following screenshot

Auto Delete System Generated Chatter Post

Don’t forget to active the Process by clicking on the Activate button

It’s time to test this App

Now onwards if a business user converts a lead, then Process Builder will automatically trigger and Launch the Flow then it will delete the system generated post after a few minutes. 

1. Below is the current status of lead “Ms. Kristen Akin” before conversion, as shown in the following screenshot

Lead status before conversion
Lead status before conversion

2. The next step is to convert the link. After successful conversion you will redirect to account detail page, as shown in the following screenshot

Account detail page
Account detail page

3. Wait a few minutes and refresh the account detail page and check out the account feed

Final Output
Final Output

Note:-  I will suggest you to implement this first on your developer org test it and then move it to Production.

Getting Started with Process Builder – Part 16 (Creating Custom Record Sharing Logic)

Posted on Updated on

Share

Salesforce allows you to control access to data at many different levels i.e. object-level, the record-level and the field-level. Here we will focus on methods for controlling access to data at the record-level. In the most of scenario you can use Out-of-box sharing settings to grant record access, but there are few use cases where  you have to write an Apex Managed Sharing to share the records with users or groups. Apex Managed Sharing allows you to use Apex Code to build sophisticated and dynamic sharing settings that aren’t otherwise possible. In this article I will show you how can use Flow and Process Builder to solve these requirements instead of using Apex code. Let’s start with a business use case

Business Use case:-  Warren Mason is working as System administrator in Universal Container. Currently he is working on a project that is implementing an audit management for Assets. For this he has created a custom object Audit (OWD :- private) and few custom fields as Shown in the following screenshot

Audit Custom Object
Audit Custom Object

Now business requirement is as soon as Auditor__c (Lookup of User object) field gets populated then auto share the audit record (Grant edit access) with the auditor.

Solution of above business requirement

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 you have to understand the sharing table in Salesforce. All objects that have a default sharing setting of the either “Private” or “Public Read Only” also have a related “Share” object that is similar to an access control list (ACL) found in other platforms. All share objects for custom objects are named as CustomObject__Share, where CustomObject__c is the name of the related custom object. A share object includes records supporting all three types of sharing i.e. Force.com managed sharing, user managed sharing, and Apex managed sharing. Share object contains few fields those are following

A. ParentId :- The Id of the record being shared. This field cannot be updated.
B. UserOrGroupId :- The Id of the User to whom you are granting access.
C. AccessLevel :- The level of access that the specified User or Group has been granted.
D. RowCause (aka Sharing Reasons) :- The reason why the user or group is being granted access.

First of all we will create an Apex Sharing Reasons. Each Apex sharing reason has a Label and a Name. The Label value is displayed in the Reason column when viewing the sharing for a record in the user interface. This allows users and administrators to understand the source of the sharing. Follow the below instructions to create a Flow and Process Builder to solve the above business requirement

1. To create Apex Sharing Reasons click on Setup | Build | create | Objects | Audit then navigate to Apex Sharing Reasons related list and click on the New button

Apex Sharing Reasons
Apex Sharing Reasons

You can enter any words or phrase for Apex Sharing Reasons. The next step is to create a Flow .

2. Click on Setup | Build | create | Workflows & Approvals | Flows
3. Click on New Flow, it will open the Flow Canvas for you. Create two text variables VarT_AuditId  and VarT_AuditorId as Shown in the following screenshot

Text Variables
Text Variables

4. The next step is to create a record on the Audit_Share object to share the record with the auditor at run time. For this drag-and-drop Record Create Element (Give the name Share audit record with Auditor) on the Flow Canvas and fill the details as shown in the following screenshot

Record Create - Create a Audit_Share record
Record Create – Create a Audit_Share record

Once you are done click on OKFinally your Flow will look like the following screenshot, click on icon that mark in red to set as start point

Share record with auditor

 5. Save your flow with name Share record with auditor and close the canvas. Don’t forget to Activate the Flow.

Launch a Flow from Process Builder

Our next task is to create a Process on Audit object to launch a Flow. To create a Process on the Audit object follow the below instructions

1. Click on Name | Setup | App Setup | Create | Workflows & Approvals | Process Builder  and click on the New button, Enter Name, API Name and click on the Save button
2. Click on Add Object, select Audit object and for the entry criteria, Select when a record is created or edited, as shown in the below screenshot and also click on the Save button

Evaluation Criteria
Evaluation Criteria

3. The next task is to add Process Criteria, To do this click on Add Criteria, enter Name, Type of action and set filter conditions  (In this case set [Audit__c].Auditor__c Is null False) and click on the Save button, as shown in the following screenshot

Process Criteria
Process Criteria

4. Our final task is to add Immediate action to Process. Click on Add Action (Under Immediate actions), Select the type of action to create (In our case Flows) , and then fill out the fields to define the action, as shown in the following screenshot

Add action – Flows
Add action – Flows

5. Once you are done, click on the Save button, it will redirect you to Process canvas. Finally the Process will look like the following screenshot

Creating Sharing Rules with Flow

Don’t forget to active the Process by clicking on the Activate button

It’s time to test this App

Now onwards if a business user creates an audit record with auditor then Process Builder will automatically trigger and Launch the Flow then it will share the audit record with the auditor. 

1. Currently audit “Dell PowerEdge Tower Servers” doesn’t have an auditor, as shown in the following screenshot

Audit record before update
Audit record before update

2. Now update the audit record with valid auditor, as shown in the following screenshot

Audit record after update
Audit record after update

3. To verify the outcome click on the sharing button available on the record detail page and check out the sharing detail as shown in the following screenshot

Final Outcome

Note:-  I will suggest you to implement this first on your developer org test it and then move it to Production.

Getting Started with Process Builder – Part 15 (An introduction to version control)

Posted on Updated on

Version ControlTill now we have created several Processes, but we haven’t tried to update an existing Process. In this article we will discuss how to update an existing activated Process or in other word you can say how to version control an existing Process in Process Builder. The Spring’15 release has rolled and now you can able to use version control in Process Builder.

What is version control?

Version control is a system that records changes to a file or set of files over time so that you can recall specific versions later. 

What is the need of version control in Process Builder ?

As you all are aware, there are no such concepts in Workflow rule then why we need a version control mechanism in Process Builder. This is because of Process Builder is nothing but a combination of Flow and Workflow rule and we can’t modify an activated Flow. It means once you have activated a Flow and want to make some changes to the same Flow, in that case you end up creating a new version. Let’s start with a business use case

Business Use case:-  Martin Jones is working as System administrator in Universal Container. He had created a process to Auto assign Price book based on Opportunity Record Type in the article Getting Started with Process Builder – Part 14. Now his organization wants to implement this for one more record type, i.e. Telecommunications then assign a price book Telecommunications (15 digit price book Id) :- 01sB00000006aec

Solution of above business requirement

As we discussed once Process gets activated it’s not possible to make any changes to it. Now we have two options that is save existing/activated process as

  • Version of current process
  • New Process

To solve the above business requirement, we will save existing activated Process as a new version. Follow the below instructions to modify the existing Process for the above business requirement

1. Click on Name | Setup | App Setup | Create | Workflows & Approvals | Process Builder, it will redirect you to the Process management page
2. Click on the Process name i.e. Auto assign Pricebook based on Opportunity Record Type as shown in the following screenshot

Process Management page
Process Management page

3. Now click on the Clone button available on top right of the Process detail page, as shown in the following screenshot

Clone existing Process
Clone existing Process

4. It will popup a window where you have to select Version of current process and enter the Name, optionally you can enter Description. Finally it will look like the following screenshot

Save Process as new version
Save Process as new version

Once you are done, click on the Save button, but it doesn’t allow you to change the API Name of a Process. You can have a maximum of 50 versions of a Process.

5. The next step is to modify the Process as per the above business requirement and finally it will look like the following screenshot

Automatically assign Price book based on Opportunity Record Type – Modified version
Automatically assign Price book based on Opportunity Record Type – Modified version

Don’t forget to active the Process by clicking on the Activate button. The new version will become the active version and the others remain as Inactive.