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.
We have used and implemented custom logic into NetCoreForce
. To get more information about it's functionality the client documentation can be found here
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
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 => Build => Create => Apps"
Under the "Connected 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/callback
Click Use digital signatures
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
CertGen
as well, code is linked below
Add Selected OAuth Scopes.
An example of these scopes might be:
full
api
refresh_token,offline_access
Click Save
There's a button called: "Manage Consumer Details" - This will show your consumer key and consumer secret. Store them.
Click the "Manage" button at the top of the connected app, and then "Edit policies"
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"
To create a self signed cert that is valid for 5 years using Perigee:
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:
Make sure to configure your own:
Certificate
Consumer key
Consumer secret
User
Domain
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