Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
cwarden committed Sep 11, 2024
1 parent 265aa13 commit c9cbd3a
Showing 1 changed file with 14 additions and 61 deletions.
75 changes: 14 additions & 61 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
batchforce
==========
# batchforce

A go library and CLI to make bulk updates in Salesforce using a SOQL query and the Bulk
API.
A command-line application to make bulk updates in Salesforce using the Bulk API.

* Use a SOQL query to retrieve the input data.
* Use an expr expression to transform the input into the data to load into Salesforce

The active [force CLI](https://github.com/ForceCLI/force) login is used, so log
in using `force login` or set your active user using `force active -a
<username>` before running your application.

Installation
============
## Installation

Download the latest release from
https://github.com/octoberswimmer/batchforce/releases. Executables are
available for Windows, Linux and MacOS.

Install from source:
```
$ go install github.com/octoberswimmer/batchforce/cmd/batchforce
$ go install github.com/octoberswimmer/batchforce/cmd/batchforce@latest
```

CLI Example
===========
## Example Usage

Each record is made available to [expr](https://github.com/antonmedv/expr/blob/master/docs/Language-Definition.md) as
`record`. The expr expression should evaluate to a single map or an array of
Expand All @@ -31,8 +35,7 @@ This will query all Accounts whose Name doesn't end with "Test" and append "Test

See [docs/batchforce.md](docs/batchforce.md) for all supported commands.

CLI Help
========
## CLI Help

```
$ batchforce help
Expand Down Expand Up @@ -95,53 +98,3 @@ Flags:
Use "batchforce [command] --help" for more information about a command.
```

Library Example
===============

```go
package main

import (
batch "github.com/octoberswimmer/batchforce"
force "github.com/ForceCLI/force/lib"
"time"
)

var (
fiftyYearsAgo = time.Now().AddDate(-50, 0, 0)
thirtyYearsAgo = time.Now().AddDate(-30, 0, 0)
)

func main() {
query := `
SELECT
Id,
Birthdate
FROM
Contact
WHERE
Birthdate != null
`

batch.Run("Contact", query, setTitle)
}

func setTitle(record force.ForceRecord) (updates []force.ForceRecord) {
birthdate, err := time.Parse("2006-01-02", record["Birthdate"].(string))
if err != nil {
return
}
update := force.ForceRecord{}
update["Id"] = record["Id"].(string)
switch {
case birthdate.Before(fiftyYearsAgo):
update["Title"] = "Geezer"
updates = append(updates, update)
case birthdate.After(thirtyYearsAgo):
update["Title"] = "Whippersnapper"
updates = append(updates, update)
}
return
}
```

0 comments on commit c9cbd3a

Please sign in to comment.