Note: – Instead of using Workflow Rules you can use Process builder. I will suggest you to replace Workflow Rule 2 with Process Builder.
In Salesforce Chatter Group represent a group of users. It’s a great way to boost collaboration in your organization. You can add unlimited members to Chatter Group, but a user can join maximum of 100 Groups. If Chatter Group is set to Private then you have to request to join and Salesforce will send an email to all group Owners and managers. What if the Group owner’s or managers forgot to take action, Salesforce never sends a reminder email.
Business Use Case
Higher management at Universal Container wants to a develop an automated process, so it will send email reminders to private Chatter Group (Group name: – Chatter Internal) owners or managers unless and until no request are pending to join the Chatter Group.
A solution for the above business requirement
To solve this requirement we will use Visual Workflow, Send Email Static action (From Flow Summer’14 enhancement) to send an email alert. Workflow rule to fire Flow Trigger. Before proceeding you have to understand CollaborationGroupMemberRequest objects in Salesforce. We need these three values
1) CollaborationGroupId: – ID of the private Chatter group.
2) RequesterId: – ID of the user requesting to join the group
3) Status: – The status of the request. Available values are: Accepted, Declined, Pending
First, create a custom object (Pending invitation) to Schedule Chatter Group pending membership request email reminder. Also Create the fields that mentioned below
Name | Data Type | Required | Description |
Chatter Group_ID
|
Text(43) | Yes | Use this field to enter Private Chatter Group ID |
Fire | Checkbox | No | Set/Reset by WFR |
Group Owner | Lookup (User) | Yes | Use this field to select group Owner |
We will create separate record for each Private Group. We will use two workflows to fire Flow Trigger for every hour (i.e. one hour) . workflow1 will contain one time-dependent action (every hour) i.e. to set Fire flag True. As soon as Fire flag set to True it will trigger another workflow2 and this is responsible to fire our Flow Trigger and set Fire flag to False.
Note: – We can’t use Flow Trigger (Pilot) with time-based Workflow. That’s why I am using two workflows.
Now we will create a flow to send a reminder to Chatter Group pending membership request. To do that follow the below instructions
1) Click on Name | Setup | App Setup | Create | Workflows & Approvals | Flows
2) Click on New Flow, it will open flow canvas for you.
3) Create Three text type variable ChatterGroupID, OwnerEmailaddress and PendingRecordID (to pass Chatter Group ID, Email address to send an email alert and Pending record ID).
4) Drag and drop a Record Lookup ( Give the name Group Request Pending) onto the window and map the fields according to below details ( This Record Lookup will check whether any pending membership request exist of particular private Chatter group)
- Select Object CollaborationGroupMemberRequest
- CollaborationGroupId= {!ChatterGroupID}
- RequesterId = {!$GlobalConstant.EmptyString} [This is a global constant]
- Status= Pending Group ID save Id of record into any variable in my case I am used variable {!Pending} . You can take help from the following screenshot
5) Now add one Decision element to decide whether our variable{!Pending} contains any value or not (If a variable doesn’t contain the value it means there are no pending request for membership). If the variable is not equal to null then go ahead else do nothing. You can take help from below screenshot to create Decision element
6) Next step is to send an email alert to group Owner. For this, we will use Send Email static action introduced in Summer’14 release. Drag and drop a Send Email static action ( Give the name Send en email alert) onto the window and map the fields according to below details
- Email Addressess= Set to variable {!OwnerEmailaddress}
- Body= There is some request pending for your approval.
https://cs5.salesforce.com/{!ChatterGroupID} - Subject = User asked to join the group
7) Finally, our flow will look like the following screenshot
8) Save the flow with the name ( Auto reminder email) and Close the canvas.
Create Workflow rule to fire our Flow
Our next task is to create a workflow on a Pending Invitation object on”created, and any time it’s edited to subsequently meet criteria” event. To create a workflow on the Pending Invitation object follow the below instructions
1) Click on Name | Setup | App Setup | Create | Workflows & Approvals | New Rule
2) Select object Pending Invitation from the drop-down
3) Enter Name, for Evaluate criteria select Created, and any time it’s edited to subsequently meet criteria ( To create a time dependent workflow), For Rule Criteria select Pending invitation Name, Chatter Group_ID Not equal to null and Fire equals to False as shown in the following screenshot
4) Now Add a time trigger to set Fire flag True after 1hr of record last modification 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 selected 1hr after the Last Modified Date. Now add one field update action for time-dependent workflow and set Fire flag to True. You can take help from the following screenshot
5) Save the workflow and activate it.
6) Create another workflow (i.e. workflow2 ) on the same object with below details. You can take help from the following screenshot
7) Add one Immediate Workflow Actions i.e. New Flow Trigger and Select Flow ( Auto reminder email) and set Variable (ChatterGroupID, OwnerEmailaddress, and PendingRecordID ) value as shown in the following screenshot
8) Add one Immediate Workflow Actions i.e. New Field Update and Set Fire flag to False. Finally, our workflow2 will look like the following screenshot
9) Save the workflow and activate it.
It’s time to test this feature
1) Now create one record for object Pending invitation for one of the Private Chatter Group for which you want to test this functionality, it will look similar to below screenshot
2) To check time-dependent workflow queue Follow the path, Click on Name | Setup | Administration Setup | Monitoring | Time–Based Workflow and search the queue.
3) The email will look like the following screenshot