1
- batchforce
2
- ==========
1
+ # batchforce
3
2
4
- A go library and CLI to make bulk updates in Salesforce using a SOQL query and the Bulk
5
- API.
3
+ A command-line application to make bulk updates in Salesforce using the Bulk API.
4
+
5
+ * Use a SOQL query to retrieve the input data.
6
+ * Use an expr expression to transform the input into the data to load into Salesforce
6
7
7
8
The active [ force CLI] ( https://github.com/ForceCLI/force ) login is used, so log
8
9
in using ` force login ` or set your active user using `force active -a
9
10
<username >` before running your application.
10
11
11
- Installation
12
- ============
12
+ ## Installation
13
+
14
+ Download the latest release from
15
+ https://github.com/octoberswimmer/batchforce/releases . Executables are
16
+ available for Windows, Linux and MacOS.
13
17
18
+ Install from source:
14
19
```
15
- $ go install github.com/octoberswimmer/batchforce/cmd/batchforce
20
+ $ go install github.com/octoberswimmer/batchforce/cmd/batchforce@latest
16
21
```
17
22
18
- CLI Example
19
- ===========
23
+ ## Example Usage
20
24
21
25
Each record is made available to [ expr] ( https://github.com/antonmedv/expr/blob/master/docs/Language-Definition.md ) as
22
26
` record ` . The expr expression should evaluate to a single map or an array of
@@ -31,8 +35,7 @@ This will query all Accounts whose Name doesn't end with "Test" and append "Test
31
35
32
36
See [ docs/batchforce.md] ( docs/batchforce.md ) for all supported commands.
33
37
34
- CLI Help
35
- ========
38
+ ## CLI Help
36
39
37
40
```
38
41
$ batchforce help
@@ -95,53 +98,3 @@ Flags:
95
98
96
99
Use "batchforce [command] --help" for more information about a command.
97
100
```
98
-
99
- Library Example
100
- ===============
101
-
102
- ``` go
103
- package main
104
-
105
- import (
106
- batch " github.com/octoberswimmer/batchforce"
107
- force " github.com/ForceCLI/force/lib"
108
- " time"
109
- )
110
-
111
- var (
112
- fiftyYearsAgo = time.Now ().AddDate (-50 , 0 , 0 )
113
- thirtyYearsAgo = time.Now ().AddDate (-30 , 0 , 0 )
114
- )
115
-
116
- func main () {
117
- query := `
118
- SELECT
119
- Id,
120
- Birthdate
121
- FROM
122
- Contact
123
- WHERE
124
- Birthdate != null
125
- `
126
-
127
- batch.Run (" Contact" , query, setTitle)
128
- }
129
-
130
- func setTitle (record force .ForceRecord ) (updates []force .ForceRecord ) {
131
- birthdate , err := time.Parse (" 2006-01-02" , record[" Birthdate" ].(string ))
132
- if err != nil {
133
- return
134
- }
135
- update := force.ForceRecord {}
136
- update[" Id" ] = record[" Id" ].(string )
137
- switch {
138
- case birthdate.Before (fiftyYearsAgo):
139
- update[" Title" ] = " Geezer"
140
- updates = append (updates, update)
141
- case birthdate.After (thirtyYearsAgo):
142
- update[" Title" ] = " Whippersnapper"
143
- updates = append (updates, update)
144
- }
145
- return
146
- }
147
- ```
0 commit comments