SalesForce
Force Client
The PerigeeSalesForceClient is an easy to use implementation on top of NetCoreForce that allows you to connect and authorize easily. It manages the token refreshes and local disk persistence as well as provides several additional methods for easy communication to SalesForce.
Authorization
There are two ways to authorize and keep the connection automatically active.
The Consumer Key and Consumer Secret are from the connected application
Username (or password if using UserPass flow) are the login user details
If using JWT, you'll supply the Certificate and optional password that was uploaded to the connected application
//Username Password
var client = PerigeeSalesForceClient.UsernamePassword(
consumerKey, consumerSecret,
user, pass);
//JWT
var client = PerigeeSalesForceClient.JWT(
consumerKey, consumerSecret,
user, new X509Certificate2("SF.pfx", "ABCD123"),
"login");Once connected with either of the two methods mentioned above, you'll have full access to the available commands!
Connected Applications
To get to the connected applications in SalesForce, go to "Setup ⇒ External Client App Manager"
Under the "External Client Apps" Create or Edit one
Enter a Name and Contact Email
Click the box: Enable OAuth Settings
Enter a Callback Url, something like:
https://login.salesforce.com/services/oauth2/callbackClick Flow Enablement ⇒ Enable JWT Bearer Flow
Upload a certificate (.cer file) (it can be self-signed)
One option for creating a certificate is the
Java Key Tool.Perigee ships with a
CertGenas well, code is linked below
Add Selected OAuth Scopes.
An example of these scopes might be:
full
api
refresh_token,offline_access
Click Save
Click the button to show your consumer key and consumer secret. Store them.
Click the "Policies" tab of the connected app, and then "Edit" ⇒ OAuth Polcies
Setup the polices as you need.
An example of this would be:
Permitted Users: "Admin Approved users are pre-authorized"
IP Relaxation: "Relax IP restrictions"
Examples
Our little demo model class is available here. As you can see, we've used Newtonsoft to remap "Name" to "AccountName".
Describe an SObject
To perform a single describe call:
Get Objects
There are a bunch of ways to get objects, including Querying for them. You may also supply direct IDS in a few ways as well:
If you're going to be calling the auto-mapped version frequently, please cache the map results and supply them to the GetObjectsAsync call as shown:
Watch for changes
We provide an asynchronous block that automatically does all the date time handling, offsets, delays, authentication paramaters, etc. You can easily start or stop this process and it will pick up from the last set of records that were sent through.
Helper watch method
To add a watch directly from Perigee Startup as a Managed Thread:
Update a record
There are two easy ways to update a single record
Query + SOQL
To execute a query, simply supply the query along with a class to map back to:
Many other methods
For the full list of methods and other ways of working with SalesForce, please visit the GitHub page!
Last updated
