How to Use Customer Data on Salesforce as Choices

Utilization of the Function, "Service Task (Choice update)", which has been Added since Version 9.9

You may also wish to use master data that is managed by an external system in Questetra BPM Suite. In this article, I am going to work on incorporating customer data managed by Salesforce into Questetra BPM Suite, and using it as the options in a select-box.

As a framework of the mechanism, it is as follows.

Blog-Salesforce-en

Retrieve customer data in Salesforce via APIs. Then, using the new function “Service Task (Choice Master Update)” added at 9.9.0, the data is imported as an “Option Master” of Questetra BPM Suite. I will do this with one App.

In the App where you want to use customer data retrieved from Salesforce as options, you have to specify the aforementioned “Options master” in the option setting of the Select type Data Item.

In this article, I will explain how to create an App that takes in Salesforce customer data as Options Master which is the first half of the process mentioned above. The App I created as an example is the following.

The general outline is as follows.

  1. Connect to Salesforce APIs at “Connect to API”, a “Throwing Message Intermediate Event (HTTP)”. Acquire customer data and store it in String type Data Item.
  2. At the script task “Parse response”, it parses the response text (JSON) acquired in 1) and puts it in a state which can be used as a select type Data Item.
  3. At the “Master update”, a Service Task (Choice update), the option of the Select type data item created in 2) is saved as the Option Master.

There are two human Tasks, the first Task is to Start the Process. And the middle “Confirmation” Task is for checking the Select type Data Items composed in 2). The gateway (split) is for preventing processing of subsequent processes when there is an error in the Salesforce API access.

I will explain the main setting of the App. The necessary data items are as follows.

Number Name Data type Description
0 Normal response String type multiple lines Response when customer data is acquired from force.com
1 Error String type multiple lines Error contents when an error occurs when acquiring customer data from force.com
2 Customer ID list String type multiple lines As a result of parsing the JSON response, a string storing the customer ID list
3 Customer name list String type multiple lines As a result of parsing the JSON response, a string storing the customer name list
4 Customer data Select type Radio button Data items for use in Service Task (Choice update)

1-1. Acquire customer data from Force.com

Call the API of Force.com using the Throwing Message Intermediate Event (HTTP) and retrieve customer data. The API we use is the Force.com REST API Query.

Configuration name Value Description
Access URL https://na10.salesforce.com/services/data/v29.0/query/
HTTP Method GET
String type data item that stores the error contents when an error occurs Error Specify Number 1, String type data items multiple lines.
Security
Connect with OAuth 2.0
設定名 Force.com Configuration name Force.com It can be any value, but it must match the OAuth 2.0 Configuration name to be described later. The details of setting up OAuth 2.0 will be described later.
Response
Save response as data Check
Data item of save destination Normal response Specify Number 0, String type data items multiple lines.

The Send parameters are as follows.

Parameter name Value Description
q SELECT Id, Name from Account

In this API, a query referred to as SOQL (Salesforce Object Query Language) which is similar to SQL is executed and the resulting object is acquired. In the query referred as “SELECT Id, Name From Account”, the ID attribute and the Name attribute are acquired from the Account object. The Account object is a standard object of Salesforce that represents customer data. In the Object Reference, you can see what kind of objects there are.

1-2. Set up OAuth 2.0 in Salesforce

In order to connect to Salesforce API from Questetra BPM Suite with OAuth 2.0, you need to make settings on the Salesforce side. Create a new “Connected App” from “App < Create < App Setup". The contents of the settings are described below. Although there are many setting items in Salesforce, you can leave the information items not included in the list below blank. Salesforce NewApplication

Configuration name Value Description
Connected App Name Questetra BPM Suite It can be any value
API Name QBPMS Any value can be set, but spaces and symbols cannot be used.
Contact Email Set the email address of the person responsible of this setting.
Enable OAuth Settings Check
Callback URL https://*****.questetra.net/PMM/ProcessModel/OAuth2/callback Copy the value described in the OAuth 2.0 setting of Questetra BPM Suite and paste it.
Selected OAuth Scopes Access and manage your data (API), Perform requests on your behalf at any time (refresh_token, offline_access) Add these two to “Selected OAuth Scopes”

1-3. Set up OAuth 2.0 in Questetra BPM Suite

In the “Security” tab on the property screen of the Throwing Message Intermediate Event (HTTP), check on “Connect with OAuth 2.0” and clicking on the “Set up OAuth 2.0 from here.” button to open the OAuth 2.0 setting screen. Add the OAuth 2.0 setting in the screen.

Questetra BPM Suite OAuth2 Setting

Configuration name Value Description
Name Force.com It must be the same as the Configuration name specified in the Throwing Message Intermediate Event (HTTP).
Authorization Code Request URL https://login.salesforce.com/services/oauth2/authorize
Access Token Request URL https://login.salesforce.com/services/oauth2/token
Scope You can leave it empty.
Consumer Key On the connection application screen of Force.com, copy the value of what is indicated as “Consumer key”.
Consumer Secret On the connection application screen of Force.com, copy the value of what is indicated as “Consumer Secret”.

After saving the setting, click on “Get Token” button to start the processing of acquiring OAuth 2.0 Token from Salesforce. If the settings are correct, the processing is completed through the screen as shown below, asking whether to allow Questetra BPM Suite to connect to Salesforce. If a Token has been acquired successfully, a circle mark is indicated in the column “Have a Token?”

Salesforce OAuth2 allow

2. Parsing on API response

Using the script task, parse the JSON text which is the response of the API. Parse the JSON text and temporarily put it in a state which can be used as options of the Select type Data Item. The format of the API response is as the following.

{"totalSize":16,
 "done":true,
 "records":[
  {
   "attributes":{
    "type":"Account",
    "url":"/services/data/v29.0/sobjects/Account/001A0000002wEMkIAM"
   },
   "Id":"001A0000002wEMkIAM",
   "Name":"United Oil & Gas, UK"
  },{
   "attributes":{
    "type":"Account",
    "url":"/services/data/v29.0/sobjects/Account/001A0000002wEMlIAM"
   },
   "Id":"001A0000002wEMlIAM",
   "Name":"United Oil & Gas, Singapore"
  },{
   ...
  }]
}

We configure this response as options for the Select type Data Item of “Customer data”. Since it is supposed to be set to use the values of two String type Data Items as options, in the script task, a list of IDs and a list of customer names is stored respectively in these two String type Data Items.

Configuration name Value Description
Specify options by String type Data Item
Option ID Customer ID list Specify the String type Data Item which stores Customer ID list at the Script Task
Label Customer name list Specify the String type Data Item which stores Customer name list at the Script Task

The following is the code included in the Script Task.

var text = data.get("0");
var result = JSON.parse(text); // Parsing JSON

var ids = "";
var labels = "";
for (var i = 0; i < result.records.length; i++) {
  var account = result.records[i];
  ids += account.Id + "\n"; // Acquire ID
  labels += account.Name + "\n"; // Acquire Name
}

retVal.put("2", ids);
retVal.put("3", labels);

If everything is OK up until this point, the customer data acquired from Salesforce should be displayed as options of Select type Data Item, “Customer data”, at the Task of “Confirmation”.

3. Saving to Options Master

At the end, we set up “Service Task (Choice update)” to save to the Options Master. Specify a select type Data Item we composed at 2).

Configuration name Value Description
User who updates the Options Master (System administration authorization required) (You) Only the user who is editing this App (that is you) can change it. If you do not have System administration authority, ask someone who has the necessary authorization set it up.
Select type Data Item which saves its own options list as “App-shared add-on” Customer data
Filename for saving to an App-shared add-on Customer Master Any value can be used.

Executing a Process on this App, the customer data for Force.com will be saved as an options master. You can confirm the saved options master at the “App-shared add-on” function in the App Settings menu.

Choices of Salesforce Customer Data

Last, I attach the App I created this time. Since the OAuth 2.0 setting is not included in the archive, you need to set this part properly. In addition, the API used this time has an upper limit on the number of data that can be acquired. If the upper limit is exceeded, it is possible to acquire subsequent data, but this App does not support it.

Next time I would like to introduce a small tip when using saved Force.com customer data as options.
 

(Original in Japanese 2014-05)
Recommendations
Prev article - 15. Ambitions Who should Change the Work Style First?
Another article - Hatanaka Akihiro Call Center with Twilio, without Telephone Machine (‘Please wait for a few seconds.’ in Japanese)

Archive

 RSS