Posted at 10:25 AM by Rakesh Gupta, on December 11, 2020
Big Idea or Enduring Question:
How do you allow your users to preschedule Chatter posts?
Chatter is a great way to boost collaboration in your organization. You can Post Status, Links, Files, and Comments on others’ posts, etc. Many time I found on Trailblazer community people is asking about a way to Preschedule Chatter Posts. But Salesforce doesn’t have any out-of-the-box feature for this, so the next way is to use the AppExchangeapp.
In this article, I will show, how you can develop your own app for scheduling Chatter Posts too without code.
Objectives:
After reading this blog post, the reader will be able to:
Use After-save Record-Triggered Flow to create a record
Use After-save Record-Triggered Flow to delete a record(s)
Add a Scheduled Paths action in After-save Record-Triggered Flow
Monitor Time-based flow queue
Business Use case
Pamela Kline is working as a System administrator at Universal Containers (UC). She has received a requirement from the management to allow their users to preschedule Chatter posts. Which will help them to schedule posts ahead of time, for example, birthday wishes, or other important announcements.
Automation Champion Approach (I-do):
Salesforce now (After Spring’21 Release) allows you to add time-dependent actions in the Flows, similar to the Process Builder.This is a major enhancement that will ultimately bring Flow to the next level.
There are few solutions possible for the above business scenario, but we’ll use After-save Record-Triggered Flowto solve it.Check out this articleto understand why we are using after-save record-triggered flow for this scenario.
Before proceeding ahead, you have to understand the FeedItemobject. It represents an entry in the feed, such as changes in a record feed, including text posts, link posts, and content posts.
Field Name
Details
Body
This is the message that appears in the feed.
ParentId
The ID of the object type to which the is related. For example, set this field to a UserId to post to someone’s profile feed, or a GroupId to post to a specific Group.
Type
The type of feed item. In our case it’s Textpost.
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 2 steps to solve Pamela’s business requirement using After-save Record-Triggered Flow. We must:Read the rest of this entry!
Posted at 2:42 AM by Rakesh Gupta, on December 5, 2020
Big Idea or Enduring Question:
How do you provide a way for deleting the Chatter group feed to the key users?
Chatter Group is primarily geared towards boosting collaboration among users within an organization. Similar to a public group, a Chatter group comprises a set of users. Indeed, one can add unlimited users to a Chatter Group.
Some time the Chatter group is very cluttered that as a manager, you want to delete the old post. There are a few apps available on AppExchange for this purpose, but nothing comes out-of-the-box. In this article, we will create automation that allows users to delete a specific type of posts for Chatter groups.
Objectives:
This blog post will help us to understand the following
Use a Screen a flow to take the user input
How to delete the records using the delete records element
Understand how to create a custom permission
Understand how to use custom permission to hide a component
Business Use Case
Brenda David is working as a System administrator at Universal Containers (UC). She has received a requirement from the management to create a wizard that allows a set of users to delete posts (created before a specific date) from Chatter groups.
Automation Champion Approach (I-do):
While this can be solved using various tools:
Manual Deletion
Lightning Web Component
Apex Code
Data Loader
We will use Salesforce Flowto solve it.
Before proceeding, ahead, understanding CollaborationGroupFeed objects in Salesforce. It represents a single feed item on a Chatter group feed.
Field Name
Details
ParentId
The Id of a chatter post.
LastModifiedId
It is the date and time when a record was last modified by a User.
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 4 steps to solve Brenda’s business requirement using Screen Flow. We must:
Salesforce Flow Steps: (Screen Flow)
Create a text variable to store chatter group id
Add a screen to capture the user data
Add a screen component
Add a Date component
Add a get record element to find collaboration group feeds created before a given date
Add a decision element to check the record collection variable (from step 1.3)
Add a delete records element to delete chatter posts
Creating a custom permission
Assign custom permission to the system administrator profile
Add flow to the chatter group page and add filter criteria
Step 1.1: Salesforce Flow – Create a Text Variable to Store Chatter Group Id
The Screen flow which we are creating will be used in the Chatter group Page to delete posts.
Click Setup.
In the Quick Find box, type Flows.
Select Flows then click on the New Flow.
Select the Screen Flowoption and click on Next and configure the flow as follows:
How do you want to start building: Freeform
Under Toolbox, select Manager. Click on the New Resource.
Input the following information:
Resource Type: Variable
API Name: varTCollaborationGroupId
Data Type: Text
Default Value: {!$GlobalConstant.EmptyString}
Check Available for Input
Check Available for Output
Click Done.
Step 1.2.1: Salesforce Flow – Add a Screen Element
Under Toolbox, select Elements. Drag and drop Screen onto the canvas.
Input the following information:
EnterLabel theAPI Name will auto-populate.
Click Done.
Step 1.2.2: Add a Date Component to Allow Users the Enter Date to Delete Past Chater Posts
Under Input section on ScreenElement. Drag and drop Date onto the screen.
Input the following information:
EnterAPI Name.
Label: Enter Date
TheAPI Name will auto-populate
Require: True
Click Done.
Step 1.3: Salesforce Flow – Adding a Get Record Element to Find Collaboration Group Feeds Created Before a Given Date
Under Toolbox, select Element.
Drag-and-drop Get Records element onto the Flow designer.
Enter a name in the Label field; the API Name will auto-populate.
Select the Record CollaborationGroupFeedobject from the dropdown list.
Select All Conditions Are Met (AND).
Set Filter Conditions
Row 1:
Field: ParentId
Operator: Equals
Value: {!varTCollaborationGroupId}
Click Add Condition
Row 2:
Field: LastModifiedDate
Operator: Less Than or Equal
Value: {!Enter_Date}
How Many Records to Store:
select All record
How to Store Record Data:
Choose the option to Automatically store all fields.
Click Done.
Step 1.4: Salesforce Flow – Using Decision Element to Check the Record Collection Variable (from step 1.3)
Now we will use the Decision element to check the Record Collection Variable from step 1.3 to find if it returns the record(s) or not.
Under Toolbox, select Element.
Drag-and-drop Decision element onto the Flow designer.
Enter a name in the Label field; the API Name will auto-populate.
Under Outcome Details,enter theLabel theAPI Name will auto-populate.
Condition Requirements to Execute Outcome: All Conditions Are Met (AND)
Row 1:
Resource: {!Find_Feeds}
Operator: Is Null
Value: {!$GlobalConstant.True}
Click Done.
Step 1.5: Salesforce Flow – Delete Records – Delete Chatter Group Posts
The next step is to add a logged-In user to the chatter group. We will use the Create Records element.
Under Toolbox, select Elements. Drag and drop Create Records onto the canvas.
Input the following information:
EnterLabel theAPI Name will auto-populate.
How Many Records to Create: One
How to Set the Record Fields: Use the IDs stored in a record variable or record collection variable
Select Record(s) to Delete
Record or Record Collection: {!Find_Feeds}
Click Done.
In the end, Brenda’sFlowwill look like the following screenshot:
Once everything looks good, perform the steps below:
Almost there! Once everything looks good, click the Activate button.
Step 2: Creating a Custom Permission
By using custom permissions, you can grant users access to custom apps. In Salesforce, you can use custom permissions to check which users can access certain functionality. Custom permissions let you define access checks that can be assigned to users via permission sets or profiles – similar to how you assign user permissions and other access settings. You can even use custom permission to bypass the validation rule for certain users or profiles. Let us create custom permission to hide the flow component.
Click Setup.
In the User Interface, type Custom Permissions.
Click on the Newbutton.
Enter Label the Name will auto-populate.
Click Save.
Step 3: Assign Custom Permission to the System Administrator Profile
Click Setup.
In the User Interface, type Profiles.
Open the System Administrator profile.
Then navigate to Apps | Custom Permission and click on the Edit button.
Now, assign the Clean Group Posts custom permission to the profile.
Click Save.
Step 4: Add a Flow to Lightning Page and Add Filter Criteria
The next step is to distribute a flow to Lightning Experience or Salesforce app users, by embedding it in a Lightning page.
Navigate to App Launcher and click on the Groups.
Open any ChatterGroup and Edit the page.
From the Lightning Components pane on the left, drag the Flow component onto the Lightning page canvas.