All Projects → owainlewis → Salesforce

owainlewis / Salesforce

A Clojure library for interacting with Salesforce.com

Programming Languages

clojure
4091 projects

Projects that are alternatives of or similar to Salesforce

Ebikes Lwc
Sample application for Lightning Web Components and Communities on Salesforce Platform. Part of the sample gallery. Retail use case. Get inspired and learn best practices.
Stars: ✭ 299 (+595.35%)
Mutual labels:  salesforce
Design System React
Salesforce Lightning Design System for React
Stars: ✭ 676 (+1472.09%)
Mutual labels:  salesforce
Lwc
⚡️ LWC - A Blazing Fast, Enterprise-Grade Web Components Foundation
Stars: ✭ 974 (+2165.12%)
Mutual labels:  salesforce
Steedos Platform
华炎魔方低代码/无代码平台。内核采用了元数据、微服务、微前端、K8S等最新的技术架构。Steedos Low-Code / No-Code Platform in nodejs and mongodb.
Stars: ✭ 310 (+620.93%)
Mutual labels:  salesforce
Sfdc Trigger Framework
A minimal trigger framework for your Salesforce Apex Triggers
Stars: ✭ 527 (+1125.58%)
Mutual labels:  salesforce
Lightning Data Grid
A data grid for Lightning Component Framework
Stars: ✭ 24 (-44.19%)
Mutual labels:  salesforce
Lightningflowcomponents
A collection of unofficial Lightning Components that can be used to enhance Salesforce Lightning Flow and Lightning Pages.
Stars: ✭ 252 (+486.05%)
Mutual labels:  salesforce
Soql Parser Js
Javascript SOQL parser
Stars: ✭ 42 (-2.33%)
Mutual labels:  salesforce
Salesforcedx Vscode
Salesforce Extensions for VS Code
Stars: ✭ 653 (+1418.6%)
Mutual labels:  salesforce
Gitignore
.gitIgnore file for Salesforce or Force.com Projects
Stars: ✭ 27 (-37.21%)
Mutual labels:  salesforce
Forceworkbench
Web-based suite of tools for administrators and developers to interact with the Force.com APIs
Stars: ✭ 380 (+783.72%)
Mutual labels:  salesforce
Npsp
The current version of the Salesforce.org Nonprofit Success Pack
Stars: ✭ 487 (+1032.56%)
Mutual labels:  salesforce
Affiliationsecurity
HEDA Affiliation-Based Security for Salesforce
Stars: ✭ 8 (-81.4%)
Mutual labels:  salesforce
Apex Recipes
A library of concise, meaningful examples of Apex code for common use cases following best practices.
Stars: ✭ 307 (+613.95%)
Mutual labels:  salesforce
Soqlbuilder
Node.js and AngularJs based Query Builder for Salesforce using OAuth2 and REST API
Stars: ✭ 37 (-13.95%)
Mutual labels:  salesforce
Sfdc Ui Lookup Lwc
Salesforce Lookup Component built with Lightning Web Components.
Stars: ✭ 285 (+562.79%)
Mutual labels:  salesforce
Squery
Salesforce SOQL query builder
Stars: ✭ 16 (-62.79%)
Mutual labels:  salesforce
Purealoe Lwc
Sample application for Lightning Web Components on Salesforce Platform. Part of the sample gallery. Agriculture and retail use case. Get inspired and learn best practices.
Stars: ✭ 43 (+0%)
Mutual labels:  salesforce
Storm Dynamic Spout
A framework for building spouts for Apache Storm and a Kafka based spout for dynamically skipping messages to be processed later.
Stars: ✭ 40 (-6.98%)
Mutual labels:  salesforce
Sails Forth
A salesforce library designed to provide idiomatic clojure representations of salesforce data and metadata
Stars: ✭ 8 (-81.4%)
Mutual labels:  salesforce

Salesforce

This is an up to date wrapper for the Salesforce.com REST API. I initially found working with the API to be a bit frustrating and hopefully this wrapper will make everything easy for you.

More information about the Salesforce REST API can be found at

http://www.salesforce.com/us/developer/docs/api_rest/

Build

Clojars Project

CircleCI

Usage

We first need to set up some authentication information as a Clojure map. All the information can be found in your Salesforce account.

In order to get an auth token and information about your account we call the auth! function like this

(use 'salesforce.core)

(def config
  {:client-id ""
   :client-secret ""
   :username ""
   :password ""
   :security-token ""})

(def auth-info (auth! config))

You can optionally pass in :login-host if you want to use test.salesforce.com or my.salesforce.com addresses

This returns a map of information about your account including an authorization token that will allow you to make requests to the REST API.

The response looks something like this

{:id "https://login.salesforce.com/id/1234",
 :issued_at "1367488271359",
 :instance_url "https://na15.salesforce.com",
 :signature "1234",
 :access_token "1234"}

Now you can use your auth-config to make requests to the API.

(resources auth-info)

Setting the API version

There are multiple versions of the Salesforce API so you need to decare the version you want to use.

You can easily get the latest API version with the following function

(latest-version) ;; => "39.0"

You can set a version in several ways.

Globally

(set-version! "39.0")

Inside a macro

(with-version "39.0"
  ;; Do stuff here )

Or just using the latest version (this is slow as it needs to make an additional http request)

(with-latest-version
  ;; Do stuff here)

SObjects

The following methods are available

  • so->all
  • so->get
  • so->create
  • so->update
  • so->delete
  • so->describe

Get all sobjects

(so->objects auth-info)

Get all records

(so->all "Account" auth-info)

Get recently created items

(so->recent "Account" auth-info)

Get a single record

;; Fetch all the info
(so->get "Account" "001i0000007nAs3" auth-info)
;; Fetch only the name and website attributes
(so->get "Account" "001i0000007nAs3" ["Name" "Website"] auth-info))

Create a record

(so->create "Account" {:Name "My Account"} auth-info)

Update a record

(so->update "Account" {:Name "My New Account Name"} auth-info)

Delete a record

(so->delete "Account" "001i0000008Ge2OAAS" auth-info)

Describe an record

(so->describe "Account" auth-info)

Salesforce Object Query Language

Salesforce provides a query language called SOQL that lets you run custom queries on the API.

(soql "SELECT name from Account" auth-info)

A sample session

This final example shows an example REPL session using the API


(def config
  {:client-id ""
   :client-secret ""
   :username ""
   :password ""
   :security-token ""})

;; Get auth info needed to make http requests
(def auth (auth! config))

;; Get and then set the latest API version globally
(set-version! (latest-version))

;; Now we are all set to access the salesforce API
(so->objects auth)

;; Get all information from accounts
(so->all "Account" auth)

;; Fetch a single account
(so->get "Account" "001i0000008Ge2TAAS" auth)

;; Create a new account
(so->create "Account" {:Name "My new account"} auth)

;; Update the account
(so->update "Account" "001i0000008JTPpAAO" {:Name "My Updated Account Name"} auth)


;; Delete the account we just created
(so->delete "Account" "001i0000008JTPpAAO" auth)

;; Finally use SOQL to find account information
(:records (soql "SELECT name from Account" auth))

;; You can also pass a clojure java.jdbc array to the soql query
;; The classes on the array will be serialized following the SOQLable protocol, which can be extended in your program.
(soql ["select * from fruits where name = ? and price >= ? and created = ?" "apple" 9/5 (java.time.LocalDate/of 2020 10 10)] auth)

Contributors

  • Owain Lewis
  • Rod Pugh
  • Lucas Severo

License

Distributed under the Eclipse Public License, the same as Clojure.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].