Salesforce1: Add/Remove Member into Chatter Group



In Salesforce Chatter Group represent group of users. It’s a great way to boost collaboration in your organization. We can add any number of users in Chatter Group. You can add unlimited members into Chatter Group, but a user can join maximum of 100 Groups. This is a daily job of Salesforce admin to Add/Remove users from a Chatter Group. As you aware that Form Salesforce1 or SalesforceA app we can’t Add/Remove user from the Chatter Group. Now let’s start with a business requirement.
Business Use case :- Higher management in Universal Container wants to develop an application for Salesforce1, from where Chatter Group admin easily Add/Remove user from the Chatter Group. They also want to make sure if a user is already a member of Chatter group then display a message otherwise add user into the group, for removal if admin is trying to remove some user those are not a part of the chatter group then display message else proceeds.
Solution of above business requirement
I think this is a good use case to start with Visual Workflow. To solve this requirement you have to use Screen,  Record Lookup, Record Create, Record delete, Decision, Dynamic choice etc. Almost you have to use all the feature from Visual Workflow. With the power of Visual Workflow, we will create an app without using a single line of code. Before proceeding you have to understand CollaborationGroup and CollaborationGroupMember objects inSalesforce.
1. CollaborationGroup :- This object represents a Chatter group.
2. CollaborationGroupMember :- This object represent a member of a Chatter groupCollaborationGroupIdrepresent Id of Chatter Group and MemberId represent ID of the user(group member).
In our app user will first select Chatter Group, In which they want to add/remove user then enter User Name in same screen. On the next they will get an option to select a User that matches with the User Name entered in the previous screen and action they want to perform Add or Remove. Then we will check whether a user is exist in the Chatter Group as member or not. Based on action we will perform addition or removal action.  On the addition If the user is not a member of Chatter Group then add else show display message. To develop add functionality follow the below instructions
Note:- In this article I will discuss only about to add into Chatter Group. In similar fashion you can develop remove functionality. I will also provide Unmanaged package of my app so you can play it within your dev org.
1. Click on Name | Setup | App Setup | Create | Workflows & Approvals | Flows
2. Click on New Flow, it will open flow canvas for you
3. Drag and drop a Screen ( Give the name Enter Details) on the window,add two fields with below details
Name
Data Type
Required
Select Chatter Group
Dropdown List (Dynamic Choice)
Yes
Enter User Name
Textbox
Yes
 To make dynamic choice (It means show the list of Chatter group from your organization) and store in one variable{!ChatterGroupID}, as shown in the below screenshot

4. Drag and drop a Screen ( Give the name Select User Name and action) on the window, Add one Dropdown List field ( Give the name Select User Group) create a new Dynamic Choice with below details
    • Select Object User
    • Enter criteria Name!= {!$GlobalConstant.EmptyString} and Isactive= {!$GlobalConstant.True}
    • Save ID in some variable in my case it’s {!UserID}, same like below screenshot

  • Add another Dropdown List field to show the action with below details.
Name
Data Type
Value
Required
Action
Dropdown List
Add
Remove
Yes

5. Now we will check whether selected user exist as a member into requested Chatter Group. To do that add oneRecord Lookup.
    • Select Object CollaborationGroupMember
    • Enter criteria CollaborationGroupId= {!ChatterGroupID} and MemberId= {!UserID}
    • Save ID in some variable in my case it’s {!MemberID}, same like below screenshot


7. If user selected Add member action then we it will redirect to the new Decision element where we will decide User already part of the Chatter Group or It’s a new member. Her we are comparing variable {!MemberID} with 0 to decide no member exist with same detail else add. You can take help from below screenshot

8. The next task is Add member to do that Drag and drop a Record Create onto the window, and map the fields as per below screenshot

  • To Display Message Drag and drop a Screen onto the window, Add one Display Text field and type message that you want to display, you can also take help from below screenshot

Finally our flow will look like below screenshot

Use this app on Salesforce1
  • To use this app on Salesforce1 , create a Visualforce Page, Select Available for Salesforce mobile apps check box and embed your Flow and crate a Visualforce Tabs to call it. Bel0w is the sample code for your reference
<apex:page >
<br/>
<Center><Font size ="6" color ="gold">Add/Remove Member Into Chatter Group</font></Center>
<br/><br/>
<style type="text/css">
.FlowText {
  color: crimson;
}
.FlowDropdown{
  color: limegreen;
}
</style>
<flow:interview name="Chatter_Group_Member"/>
</apex:page>

Now navigate to Name | Setup | Administration Setup | Mobile Administration | Mobile Navigation
  • Add you Visualforce Tabs into selected pane, as shown in below screenshot

It’s time to test this feature
To test this app open your Salesforce1 and navigate to Apps and click on your Tab (ARM Chatter Group) it will open a Visualforce page for you. In this demo I will adduser is Rakesh Gupta to the Chatter Group (Salesforce Project)and click on Next In our case Screen-1 will look like below screenshot

On the Screen-2 it will show the list of user based on user input on Screen-1. Select the User and Action from the Drop-down list and click on Next, It will look like below screenshot

On the Screen-3 it will display message as user is already member of Chatter Group (Salesforce Project)

Install this app
I am offering this app an Unmanaged package, you can install it from below URL
To install this app replace Login with your Salesforce instance name in my case this url will look like

Post a Comment

MKRdezign

Contact Form

Name

Email *

Message *

Powered by Blogger.
Javascript DisablePlease Enable Javascript To See All Widget