Salesforce Communities

Communities are branded online spaces in which employees, customers and partner can engage with one another. Organization can create branded public or private communities that connect members directly with each others with relevant data and business processes.

Communities live inside your Salesforce organization, and allow you to give external member access to subsets of your data. Access is controlled through community profiles and roles that integrate with your security model.

Nowadays customers wants to interact with their vendors and share their experience with other customers and find the relevant information as they need. Communities was built to address all of the needs.

Salesforce provide two type of communities Customer Communities and Partner Communities.

  • Customer Communities: This community enables customers to answer questions for other customers, quickly find the information they need or work with support team to resolve issues.
  • Partner Communities:  Partner communities enable organizations to manage reseller relationships by keeping information private, but they can enable collaborative selling between partners.

Using these communities, members can create and collaborate on support cases, sales opportunities or campaigns from within the community. Members can access the community from any device, anywhere. Relevant information can be shared to each members.

Steps to create Community:


Enable communities

  • From Setup, enter “Communities Settings” in the Quick Find box, then select “Communities Settings”.
  • Select Enable communities.
  • Put domain name to use for your communities, then click “Check Availability” button to make sure it’s not already being used.
  • Click “Save” button.

Create Communities: Using a wizard that helps user to choose a community template that meets their expectation.

  • From Setup, enter “Communities” in the Quick Find box, select All Communities, then click New Community.
  • The Community Creation wizard appears, with different template options for you to choose from.
  • After choosing a template, specify the categories and Company Name for your template, then click Next.
  • Enter a community name.
  • Enter a unique value at the end of the URL field.
  • Click “Create Community” button.
  • On the confirmation page, click Go to “Community Management” to customize your community.

Set the Default Number of Community Roles: Set the default number of roles created when adding partner or customer accounts to communities.

  • From Setup, enter “Communities Settings” in the Quick Find box, then select Communities Settings.
  • Select the number of roles per account.
    • If you’re using Partner Community licenses, set the Number of partner roles.
    • If you’re using Customer Community Plus licenses, set the Number of customer roles.
  • Click “Save” button.

Enable Super User Access in Communities: Enable super user access so that partner users in communities can access additional records and data.

  • From Setup, enter “Communities Settings” in the Quick Find box, then select Communities Settings.
  • Select Enable Partner Super User Access.
  • Click Save.

Grant High-Volume Community Users Access to Records:

  • From Setup, enter “Communities Settings” in the Quick Find box, then select Communities Settings.
  • In the Sharing Sets related list, click New to create a sharing set, or click Edit next to an existing sharing set.
  • In the Sharing Set Edit page, fill in the Label and Sharing Set Name fields. Label is the sharing set label as it appears on the user interface. Sharing Set Name is the unique name used by the API.
  • Enter a description.
  • Select the profiles of the users to whom you want to provide access.
  • Select the objects you want to grant access to.
  • In the Configure Access section, click Set Up or Edit next to an object name to configure access for the selected profiles, or click Delete to remove access settings for an object.
  • Grant access based on an account or contact lookup
    • Select a value in the User drop-down list to determine the account or contact lookup on the user.
    • Select a value in the Target Object field to determine the account or contact lookup on the target object.
  • Choose an access level of Read Only or Read/Write.
  • Click Update, then click Save.

Enable the Global Header for Communities: When Communities is enabled, the global header allows you to easily switch between your communities and your internal organization.

  • From Setup, enter “Permission Sets” in the Quick Find box, then select “Permission Sets”.
  • Click New and create a permission set that includes the System Permission “View Global Header”.
  • Assign the permission set to the appropriate users.

Add Members to Your Community: Permission sets allow added flexibility for adding members. You can grant community access to a subset of users from the same profile.

  • Access Community Management in either of the following ways.
    • From the community, click  in the global header.
    • From Setup, enter “All Communities” in the Quick Find box, then select “All Communities”. Then click Manage next to the community name.
  • Click Administration > Members.
  • Select a profile type from the drop-down menu. To search for a specific profile, enter a search term and click Find.
  • To add members using profiles
    • Select the user profiles you want to allow access to your community. Press CTRL to select multiple profiles.
    • Click Add. To remove a profile, select it and click Remove.
  • To add members using permission sets
    • To search for a specific permission set, enter a search term and click Find.
    • Select the permission sets you want to allow access to your community. Press CTRL to select multiple permission sets.
    • Click Add.
  • Click Save.

Add Tabs to Your Community:

  • From the community, click gear icon in the global header.
  • From Setup, enter “All Communities” in the Quick Find box, then select “All Communities”. Then click Manage next to the community name.
  • Click Administration > Tabs.
  • Select the tabs to include in your community from the Available Tabs list.
  • Click Add to add the tab.
  • Click Up or Down to change the order that the tabs display. Then click “Save” button.

Customize Login, Logout, and Self-Registration Pages in Your Community: Configure the standard login, logout, password management, and self-registration options for your community, or customize the behavior with Apex and Visualforce or Community Builder pages. By default, each community comes with default login, password management, and self-registration pages and associated Apex controllers that drive this functionality under the hood. You can use Visualforce, Apex, or Community Builder to create custom branding and change the default behavior.

Create Communities Users: To allow an external user to access your community, enable the user’s contact record as a customer user or partner user, depending on the user’s license type. Your community can contain users with Partner Community, Customer Community, and Customer Community Plus licenses.

  • To create partner users:
    • View the external account you want to create a user for.
    • Create a contact. Click New Contact from the Contacts related list. Fill in the appropriate details, then click Save.
  • On the contact detail page, click Manage External User, then Enable Partner User
    • Edit the user record for this external user:
    • Select the Partner Community user license.
    • Select the appropriate profile.
    • Deselect Generate new password and notify user immediately so that users don’t receive a password before the community is activated. When you activate the community, the user receives a welcome email with the login information, as long as the Send welcome email option is selected for the community.
    • Click Save.
  • To create customer users:
    • Create a contact.
    • On the contact detail page, click Manage External User, then Enable Customer User.
    • Edit the user record for this external user.
      • Select the appropriate profile. The available profiles are limited to the Customer Community User profile and any profiles cloned from it.
      • Remember that profiles give users access to tabs in your community, so be sure that you choose a profile that has the appropriate tabs exposed.
      • Deselect Generate new password and notify user immediately so that users don’t receive a password before the community is activated. When you activate the community, the user receives a welcome email with the login information, as long as the Send welcome email option is selected for the community.
    • Click Save.

There are lot many setting are available that you can change like:

  • Customize Email Sent from Communities.
  • Determine User Visibility in Your Community.
  • Show Nicknames Instead of Full Names in the Community.
  • Enable Public Access to Community Content.
  • Use Custom Visualforce Error Pages for Authenticated Users.
  • Limit Files in Your Community.
  • Set Up Search Engine Optimization (SEO) for Your Community.
  • Enable Cases for Communities Users.
  • Delegate External User Administration.
  • Grant Super User Access to Partner Users in Your Community.
  • Grant Super User Access to Customer Users in Your Community.
  • Make Your Communities Active:
  • Access Community Management in either of the following ways.
    • From the community, click  in the global header.
    • From Setup, enter “All Communities” in the Quick Find box, then select “All Communities”. Then click Manage next to the community name.
  • Click Administration > Settings.
  • Click Activate Community.

 

Reference

http://resources.docs.salesforce.com

Advertisements

Force.com REST API

Introduction:

REST API provide a powerful and simple Web Services API for interacting with Force.com. Its advantages is easy to integrate and development. However, REST API is the best option, if you have many records to process. REST API uses the same underlying data model and standard objects as like in SOAP API.

REST API is the best example of abstraction, such as single record, collection of records or even dynamic real-time data. REST API is identified by named URL and is accessed by using standard HTTP methods like (HEAD, GET, POST, PATCH, DELETE). REST API can be use to interact with Force.com object. For example:

  • Obtain detailed information about the Standard/Custom object.
  • Perform Query/Search options.
  • Add/Update or Delete records.

Force.com API supports OAuth an open source protocol to allow secure API authentication. It also supports for JSON and XML format. JSON is the default format for REST API, you can change this to XML. You can use many tools like PostMan or CURL to send HTTP request to access REST API.

SalesForce.com_OAuth

Authentication:

  • SalesForce.com supports OAuth protocol to allow users of application to securly access the data without having real username and password. Before making any API request, you must authenticate the application using OAuth.
  • Set up your application as a connected app in the Salesforce organization.
  • Determine the correct Salesforce OAuth endpoint for your connected app to use. Supported OAuth flows include:
    • Web server flow, where the server can securely protect the consumer secret.
    • User-agent flow, used by applications that cannot securely store the consumer secret.
    • Username-password flow, where the application has direct access to user credentials.
    • After successfully authenticating the connected app user with Salesforce, you’ll receive an access token which can be used to make authenticated REST API calls.

Creating Connected APP:

  • From Setup, enter Apps in the Quick Find box, then select Apps and click New to start defining a connected app.
  • Enter the name of your application.
  • Enter the contact email information, as well as any other information appropriate for your application.
  • Select Enable OAuth Settings.
  • Enter a Callback URL. Depending on which OAuth flow you use, this is typically the URL that a user’s browser is redirected to after successful authentication. As this URL is used for some OAuth flows to pass an access token, the URL must use secure HTTP (HTTPS) or a custom URI scheme.
  • Add all supported OAuth scopes to Selected OAuth Scopes. These scopes refer to permissions given by the user running the connected app.
  • Enter a URL for Info URL. This is where the user can go for more information about your application.
  • Click Save. The Consumer Key is created and displayed, and the Consumer Secret is created (click the link to reveal it).

Request:

curl -X POST -H “Content-Type: application/x-www-form-urlencoded” -H “Cache-Control: no-cache” -H “Postman-Token: 26a0df06-9cc6-d1a5-2945-bce6a12a40b4” -d ‘client_id=3MVG9ZL0ppGP5UrBctV8ANK6.aSwde.V2awsdMdFLRjJwx_vAoetz0GFD2iM2zoLqwefGtgFy.1b1Sx23d44fp&client_secret=6608475281234568784&grant_type=password&username=example@gmail.com&password=test@123AsqswDeXGRWCR4zMGU6xnFMz’ “https://login.salesforce.com/services/oauth2/token

Response:

{

“access_token”: “00D28000001DpSn!ARoAQCCXZeA9_98s5UnfbcpRsSE0wDgBqPoD5vApegClQfjDUkvch.ajacaVwuCreIk6AcLk3gv69SqUMR.39”,

“instance_url”: “https://ap2.salesforce.com”,

“id”: “https://login.salesforce.com/id/00D201DpEAK/00528QMAA0”,

“token_type”: “Bearer”,

“issued_at”: “1464331653427”,

“signature”: “yd5Ojy1qfPLUspdQfeEgmbIG8022w1PEg=”

}

 

SalesForce Chatter Integration

Introducing Chatter REST API:

Use Chatter REST API to display Salesforce data, especially in mobile applications. Chatter provide feeds, users, groups, and followers, Chatter REST API provides programmatic access to files, recommendations, topics, notifications, Data.com purchasing, and more. Chatter REST API is similar to APIs offered by other companies with feeds, such as Facebook and Twitter, but it also exposes Salesforce features beyond Chatter.

When to Use Chatter REST API:

  • Build a mobile app.
  • Integrate a third-party Web application with Salesforce.
  • Display a feed on an external system.

Chatter REST API Architecture:

  • To use Chatter REST API, understand a few characteristics of its architecture, like Chatter REST API uses OAuth 2.0.
  • Chatter REST API responses are minimally HTML entity-encoded by default.
  • For non-HTML contexts, such as native mobile applications, Chatter REST API clients can request raw (unencoded) output.
  • The JSON format is supported with UTF-8. Date-time information is in ISO8601 format.
  • Responses are in JSON format by default. To specify JSON, use Accept: application/json.)
  • Salesforce IDs in response bodies are always 18 character IDs. In request bodies, you can use either 15 character IDs or 18 character IDs.
  • Chatter REST API requests are subject to rate limiting. Chatter REST API has a different rate limit than other Salesforce APIs. Chatter REST API has a per user, per application, per hour rate limit. When you exceed the rate limit, all Chatter REST API resources return a 503 Service Unavailable error code.
  • For applications using a session ID from Force.com, the rate limit is per user, per hour. To take advantage of the per user, per application, per hour limit, use OAuth tokens.

Set Up Authorization: Create a connected app in a Salesforce organization and enable OAuth. The client application uses the connected app to connect to Salesforce. Let’s create a connected application on the first step to make an authentication for requester.

  • Enter a Callback URL. It must be secure: http:// does not work, only https:// works.
  • Go to Setup and create a new connected application, as shown in picture.
  • Enter a connected app name.
  • Enter the contact email, as well as any other required information.
  • Select Enable OAuth Settings.
  • Enter an OAuth scope. Select Access and manage your Chatter feed in addition to any other scope you want your connected app to allow access to and click Save.
  • The Consumer Key is created and displayed, and a Consumer Secret is created (click the link to reveal it).

SalesForce-APP

Connect to Chatter REST API Using OAuth: Use OAuth to connect to Salesforce and get an access token. Pass the access token in requests to Chatter REST API. There are multiple way you can access API but easier way is using curl. Curl Command to generate access token through connected app using command line tool. To make a request to Salesforce:

Step1:

image1

image2

Step 2: To request a user information, use the returned “id”. Pass the returned access_token as a Bearer token in the Authorization request header and get the details.

image3

image4

Step3: Post a New Comment On Chatter

image5

image6

Salesforce APIs:

Resource HTTP Methods Tasks
/chatter/feed-elements GET, POST Post feed elements and search all feed elements in an organization.
/chatter/feeds/files/me/feed-elements GET Returns all feed elements posted with files by people or groups that the context user follows.
/chatter/feeds/news/me/feed-elements GET All feed elements from all groups the context user either owns or is a member of, as well as all files, records, and users the context user follows. Use this resource to get information about feed elements and to post feed elements.
/chatter/feeds/record/recordId/feed-elements GET Returns the feed elements for all the records the context user is following, or all the feed elements of the specified recordId. Use this resource to search a feed or to get the feed elements for a specific feed, including another user’s feed. To use this resource to get the feed elements for a group, specify the group ID as the recordId.
/chatter/feeds/user-profile/userId/feed-elements GET Returns feed elements created when a user changes records that can be tracked in a feed, feed elements whose parent is the user, and feed elements that mention the user. This feed is different than the news feed, which returns more feed items, including group updates. You can post feed items to the user-profile feed. You can get another user’s user profile feed.
/connect/files/fileId GET, POST, PATCH, DELETE Get information about a specified file, including references to external files. Upload a new version of an existing file, including references to external files. Rename a file, move a file to a different folder, and delete a file.
/connect/files/fileId/content GET Returns the content of the file, including references to external files. The content is streamed as the body of the response.
/connect/files/fileId/file-shares GET, POST Returns information about the objects with which the specified file has been shared. Objects can be users, groups, or records. Can also be used to share the specified file with users.
/connect/files/fileId/file-shares/link GET, PUT, DELETE A description of a file shared as a link. Create, access, and delete a file’s share link.
/connect/files/fileId/previews GET, PATCH Get information about a file’s supported previews and generate a file preview.
/connect/files/fileId/previews/previewFormat GET Get a file preview or a specific page in a preview.
/connect/files/fileId/rendition GET A rendition of the file. A rendition is a binary preview of the file. The format of the binary depends on the format specified in the request.
/connect/files/batch/fileIds GET, DELETE Information about a list of files, specified by file IDs. Get information about a list of files and delete a list of files.
/connect/folders/folderId GET, PATCH, DELETE Get information about the specified folder. Move, rename, and delete a folder. Sync the root folder.
/connect/folders/folderId/items GET, POST Get information about the contents of a folder. Add a file to a folder and create a folder. Sync the root folder.
/chatter/groups/groupId/files GET Returns information about the files posted to the specified group.
/connect/topics/topicId/files GET Returns information about the five files most recently posted to the specified topic.
/connect/files/users/userId GET, POST Upload a file, including references to external files, to the Files home or get information about files a user owns. These files don’t include files shared with a user, files a user follows, or general organization files.
/connect/files/users/me/filter/groups GET Returns information about files posted to groups that the specified user is a member of.
/connect/files/users/me/filter/shared-with-me GET Returns information about files that have been shared with the specified user.
Reference
https://developer.salesforce.com/
http://www.oyecode.com/2014/08/start-building-your-own-rest-api-in.html