Step 2: Set up the Salesforce System
In this step, you configure Salesforce to send notifications when an opportunity is successfully closed. Before you can send notifications, you need to perform the following steps:
Create an account in Salesforce. An account represents a customer for Northwind.
Create an opportunity for the account. An opportunity represents a prospective sales opportunity with the customer. As part of the opportunity, you also add the product details that the customer is interested in.
Create a workflow in Salesforce.
Create a Salesforce connected application definition.
Note
The steps in this topic assume that you already have a Salesforce developer account. To create a new developer account in Salesforce, go to https://go.microsoft.com/fwlink/?LinkId=296424.
To create an Account in Salesforce
Log on to the Salesforce.com portal using your developer credentials.
On the portal, click the Accounts tab, and then click New.
On the New Account page, provide values for the various fields. Specifying a value for Account Name is mandatory. For this tutorial, specify the account name as
Customer1
.Click Save.
To create an Opportunity for the customer
On the Salesforce.com portal, click the Opportunities tab.
In the Recent Opportunities section, click New.
In the New Opportunity page, specify the following values:
Specify an Opportunity Name, for example,
Opportunity with Customer 1
.Specify the Account Name. This represents the account with which this opportunity is associated. For this tutorial, set the Account to
Customer1
. You created this account in the previous procedure.Specify a Close Date. This represents the date by which the opportunity should be closed.
Specify a Stage. This denotes the current stage for the opportunity. To start with, you can set the opportunity to anything, for example, Needs Analysis.
Note
Make sure you do not set the stage to Closed Won to start with. For the scenario in this tutorial, every time the stage is set to Closed Won a notification is sent to a relay endpoint on Microsoft AzureService Bus. We haven’t set up that part of the solution yet, so you should not set the stage to Closed Won.
Specify values for other optional fields and then click Save.
On the Opportunity page for Customer1, under the Products section, click Add Product.
From the list of products, select the products that the customer is interested in, and then click Select.
For each selected product, specify a quantity that the customer wants, and then click Save.
Create a Salesforce Workflow
In this step we create a workflow to send out a notification every time an opportunity is closed successfully. The notification is in the form of a SOAP message and is sent to a relay endpoint hosted on Microsoft AzureService Bus.
To create a workflow for opportunities
On the Salesforce portal, click your login name at the top right corner of the page, and then click Setup.
In the left pane, under App Setup, expand Create, expand Workflow & Approvals, and then click Workflow Rules.
Note
If you are opening the Workflow Rules page for the first time, you will be presented with some information to understand how workflows work in Salesforce. Read through the information and then click Continue.
On the All Workflow Rules page, click New Rule.
From the Select Object list, click Opportunity, and then click Next.
In the next page, specify the following:
Set the Rule Name as
Closed Opportunity
.Set the Evaluation Criteria as created, and any time it’s edited to subsequently meet criteria.
For the Rule Criteria, set to run the rule when the criteria are met.
Set Field to Opportunity: Stage, Operator to equals, and Value to
Closed Won
.Click Save & Next.
Define the workflow action for the new rule:
On the Specify Workflow Actions page, click Add Workflow Action button and then click New Outbound Message.
Set the Name and Unique Name fields to
NewOp1
.Specify a description, such as, the
Message sent when an opportunity is successfully closed
.Specify the Endpoint URL as
https://btssalesforce.servicebus.windows.net/notifications/opportunity
.Here, btssalesforce is your Service Bus namespace that you created in earlier steps. /notifications/opportunity/ represents the relay that we will create in later steps of this tutorial.
Note
You must specify the Service Bus namespace that you created earlier.
Make sure the Protected Component check box is clear and the Send Session ID check box is checked.
For Opportunity fields to send select the relevant fields from the Available Fields list and then click the Add button.
Click Save and then click Done.
In the left pane, under App Setup, expand Create, expand Workflow & Approvals, and then click Workflow Rules. Verify that the Closed Opportunity rule is listed there. Under the Action column for the Closed Opportunity rule, click Activate to activate the rule.
Create a Salesforce Connected Application
Creating a connected application definition generates a set of keys required to request OAuth tokens to access to connect to Salesforce. In the later stages of this tutorial, BizTalk Server will be the connected application that queries Salesforce using the connected application definition.
To create a connected application for Salesforce
On the Salesforce portal, click your login name at the top right corner of the page, and then click Setup.
In the left pane, under App Setup, expand Create, and then expand Apps. On the Apps page, under the Connected Apps section, click New.
In the New Connection App page, specify the following:
For Connected App Name, specify
BizTalk_Salesforce
.For Developer Name, specify your log on name.
For Contact Email, specify your e-mail.
For Callback URL, specify a valid URL.
Note
Because of the way we authenticate with Salesforce in this scenario, the value you specify here is not used.
Under Available OAuth Scopes, select Full access, Perform requests on your behalf at any time, and Access and manage your data and then click the Add button to move them into the Selected OAuth Scopes.
Click Save. The page that appears contains information about the Consumer Key and Consumer Secret. You must make a note of these values. You will need these values while connecting to Salesforce from BizTalk Server.
Finally, generate a security token required for connecting to Salesforce from unknown network locations.
On the left pane of the Salesforce portal, under Personal Setup, expand Personal Information, and then click Reset My Security Token.
Read the warning and then click Reset Security Token.
You should receive the security token at the e-mail address you specified while creating your Salesforce account.