monday_ruby 1.0.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.env +1 -1
- data/.rspec +0 -1
- data/.rubocop.yml +19 -0
- data/.simplecov +1 -0
- data/CHANGELOG.md +49 -0
- data/CONTRIBUTING.md +165 -0
- data/README.md +167 -88
- data/docs/.vitepress/config.mjs +255 -0
- data/docs/.vitepress/theme/index.js +4 -0
- data/docs/.vitepress/theme/style.css +43 -0
- data/docs/README.md +80 -0
- data/docs/explanation/architecture.md +507 -0
- data/docs/explanation/best-practices/errors.md +478 -0
- data/docs/explanation/best-practices/performance.md +1084 -0
- data/docs/explanation/best-practices/rate-limiting.md +630 -0
- data/docs/explanation/best-practices/testing.md +820 -0
- data/docs/explanation/column-values.md +857 -0
- data/docs/explanation/design.md +795 -0
- data/docs/explanation/graphql.md +356 -0
- data/docs/explanation/migration/v1.md +808 -0
- data/docs/explanation/pagination.md +447 -0
- data/docs/guides/advanced/batch.md +1274 -0
- data/docs/guides/advanced/complex-queries.md +1114 -0
- data/docs/guides/advanced/errors.md +818 -0
- data/docs/guides/advanced/pagination.md +934 -0
- data/docs/guides/advanced/rate-limiting.md +981 -0
- data/docs/guides/authentication.md +286 -0
- data/docs/guides/boards/create.md +386 -0
- data/docs/guides/boards/delete.md +405 -0
- data/docs/guides/boards/duplicate.md +511 -0
- data/docs/guides/boards/query.md +530 -0
- data/docs/guides/boards/update.md +453 -0
- data/docs/guides/columns/create.md +452 -0
- data/docs/guides/columns/metadata.md +492 -0
- data/docs/guides/columns/query.md +455 -0
- data/docs/guides/columns/update-multiple.md +459 -0
- data/docs/guides/columns/update-values.md +509 -0
- data/docs/guides/files/add-to-column.md +40 -0
- data/docs/guides/files/add-to-update.md +37 -0
- data/docs/guides/files/clear-column.md +33 -0
- data/docs/guides/first-request.md +285 -0
- data/docs/guides/folders/manage.md +750 -0
- data/docs/guides/groups/items.md +626 -0
- data/docs/guides/groups/manage.md +501 -0
- data/docs/guides/installation.md +169 -0
- data/docs/guides/items/create.md +493 -0
- data/docs/guides/items/delete.md +514 -0
- data/docs/guides/items/query.md +605 -0
- data/docs/guides/items/subitems.md +483 -0
- data/docs/guides/items/update.md +699 -0
- data/docs/guides/updates/manage.md +619 -0
- data/docs/guides/use-cases/dashboard.md +1421 -0
- data/docs/guides/use-cases/import.md +1962 -0
- data/docs/guides/use-cases/task-management.md +1381 -0
- data/docs/guides/workspaces/manage.md +502 -0
- data/docs/index.md +69 -0
- data/docs/package-lock.json +2468 -0
- data/docs/package.json +13 -0
- data/docs/reference/client.md +540 -0
- data/docs/reference/configuration.md +586 -0
- data/docs/reference/errors.md +693 -0
- data/docs/reference/resources/account.md +208 -0
- data/docs/reference/resources/activity-log.md +369 -0
- data/docs/reference/resources/board-view.md +359 -0
- data/docs/reference/resources/board.md +393 -0
- data/docs/reference/resources/column.md +543 -0
- data/docs/reference/resources/file.md +236 -0
- data/docs/reference/resources/folder.md +386 -0
- data/docs/reference/resources/group.md +507 -0
- data/docs/reference/resources/item.md +348 -0
- data/docs/reference/resources/subitem.md +267 -0
- data/docs/reference/resources/update.md +259 -0
- data/docs/reference/resources/workspace.md +213 -0
- data/docs/reference/response.md +560 -0
- data/docs/tutorial/first-integration.md +713 -0
- data/lib/monday/client.rb +41 -2
- data/lib/monday/configuration.rb +13 -0
- data/lib/monday/deprecation.rb +23 -0
- data/lib/monday/error.rb +5 -2
- data/lib/monday/request.rb +19 -1
- data/lib/monday/resources/base.rb +4 -0
- data/lib/monday/resources/board.rb +52 -0
- data/lib/monday/resources/column.rb +6 -0
- data/lib/monday/resources/file.rb +56 -0
- data/lib/monday/resources/folder.rb +55 -0
- data/lib/monday/resources/group.rb +66 -0
- data/lib/monday/resources/item.rb +62 -0
- data/lib/monday/util.rb +33 -1
- data/lib/monday/version.rb +1 -1
- data/lib/monday_ruby.rb +1 -0
- metadata +92 -11
- data/monday_ruby.gemspec +0 -39
|
@@ -0,0 +1,699 @@
|
|
|
1
|
+
# Update Items
|
|
2
|
+
|
|
3
|
+
Modify item properties and column values in your boards.
|
|
4
|
+
|
|
5
|
+
## Finding Column IDs
|
|
6
|
+
|
|
7
|
+
::: warning <span style="display: inline-flex; align-items: center; gap: 6px;"><svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"></path><line x1="12" y1="9" x2="12" y2="13"></line><line x1="12" y1="17" x2="12.01" y2="17"></line></svg>Column IDs are Board-Specific</span>
|
|
8
|
+
**Before updating column values, you must find your board's actual column IDs.** Column IDs like `status`, `text`, or `date` in these examples are placeholders - replace them with your board's real column IDs.
|
|
9
|
+
:::
|
|
10
|
+
|
|
11
|
+
Query your board to get column IDs:
|
|
12
|
+
|
|
13
|
+
```ruby
|
|
14
|
+
response = client.board.query(
|
|
15
|
+
args: { ids: [1234567890] }, # Replace with your board ID
|
|
16
|
+
select: [
|
|
17
|
+
"id",
|
|
18
|
+
"name",
|
|
19
|
+
{
|
|
20
|
+
columns: ["id", "title", "type"]
|
|
21
|
+
}
|
|
22
|
+
]
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
if response.success?
|
|
26
|
+
board = response.body.dig("data", "boards", 0)
|
|
27
|
+
|
|
28
|
+
puts "Columns for board '#{board['name']}':"
|
|
29
|
+
board["columns"].each do |column|
|
|
30
|
+
puts " • #{column['title']}: '#{column['id']}' (#{column['type']})"
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
**Example output:**
|
|
36
|
+
```
|
|
37
|
+
Columns for board 'Marketing Campaigns':
|
|
38
|
+
• Name: 'name' (name)
|
|
39
|
+
• Status: 'status' (color)
|
|
40
|
+
• Owner: 'people' (people)
|
|
41
|
+
• Due Date: 'date4' (date)
|
|
42
|
+
• Priority: 'status_1' (color)
|
|
43
|
+
• Text: 'text' (text)
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Use these exact column IDs (e.g., `date4`, `status_1`) in your update calls, not the column titles.
|
|
47
|
+
|
|
48
|
+
## Update Single Column Value
|
|
49
|
+
|
|
50
|
+
Update one column value at a time:
|
|
51
|
+
|
|
52
|
+
```ruby
|
|
53
|
+
require "monday_ruby"
|
|
54
|
+
|
|
55
|
+
Monday.configure do |config|
|
|
56
|
+
config.token = ENV["MONDAY_TOKEN"]
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
client = Monday::Client.new
|
|
60
|
+
|
|
61
|
+
# ⚠️ Replace 'status' with your actual column ID from the query above
|
|
62
|
+
response = client.column.change_value(
|
|
63
|
+
args: {
|
|
64
|
+
board_id: 1234567890,
|
|
65
|
+
item_id: 987654321,
|
|
66
|
+
column_id: "status", # Your status column ID (e.g., 'status', 'status_1', etc.)
|
|
67
|
+
value: JSON.generate({ label: "Done" })
|
|
68
|
+
}
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
if response.success?
|
|
72
|
+
item = response.body.dig("data", "change_column_value")
|
|
73
|
+
puts "✓ Updated: #{item['name']}"
|
|
74
|
+
else
|
|
75
|
+
puts "✗ Failed to update item"
|
|
76
|
+
end
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
**Output:**
|
|
80
|
+
```
|
|
81
|
+
✓ Updated: Marketing Campaign
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Update Simple Column Values
|
|
85
|
+
|
|
86
|
+
For simple column types, use `change_simple_value`:
|
|
87
|
+
|
|
88
|
+
### Text Column
|
|
89
|
+
|
|
90
|
+
```ruby
|
|
91
|
+
# ⚠️ Replace 'text' with your actual text column ID
|
|
92
|
+
response = client.column.change_simple_value(
|
|
93
|
+
args: {
|
|
94
|
+
board_id: 1234567890,
|
|
95
|
+
item_id: 987654321,
|
|
96
|
+
column_id: "text", # Your text column ID
|
|
97
|
+
value: "Updated text content"
|
|
98
|
+
}
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
if response.success?
|
|
102
|
+
item = response.body.dig("data", "change_simple_column_value")
|
|
103
|
+
puts "Updated: #{item['name']}"
|
|
104
|
+
end
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### Number Column
|
|
108
|
+
|
|
109
|
+
```ruby
|
|
110
|
+
response = client.column.change_simple_value(
|
|
111
|
+
args: {
|
|
112
|
+
board_id: 1234567890,
|
|
113
|
+
item_id: 987654321,
|
|
114
|
+
column_id: "numbers",
|
|
115
|
+
value: "42"
|
|
116
|
+
}
|
|
117
|
+
)
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
::: tip <span style="display: inline-flex; align-items: center; gap: 6px;"><svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"></circle><line x1="12" y1="16" x2="12" y2="12"></line><line x1="12" y1="8" x2="12.01" y2="8"></line></svg>Simple vs Complex</span>
|
|
121
|
+
Use `change_simple_value` for text, numbers, and simple types. Use `change_value` for status, people, date, and other complex column types.
|
|
122
|
+
:::
|
|
123
|
+
|
|
124
|
+
## Update Multiple Columns
|
|
125
|
+
|
|
126
|
+
Update several column values at once:
|
|
127
|
+
|
|
128
|
+
```ruby
|
|
129
|
+
require "json"
|
|
130
|
+
|
|
131
|
+
# ⚠️ Replace all column IDs with your board's actual column IDs
|
|
132
|
+
column_values = {
|
|
133
|
+
status: { label: "Working on it" }, # Your status column ID
|
|
134
|
+
text: "High Priority", # Your text column ID
|
|
135
|
+
numbers: 85 # Your numbers column ID
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
response = client.column.change_multiple_values(
|
|
139
|
+
args: {
|
|
140
|
+
board_id: 1234567890,
|
|
141
|
+
item_id: 987654321,
|
|
142
|
+
column_values: JSON.generate(column_values)
|
|
143
|
+
}
|
|
144
|
+
)
|
|
145
|
+
|
|
146
|
+
if response.success?
|
|
147
|
+
item = response.body.dig("data", "change_multiple_column_values")
|
|
148
|
+
puts "✓ Updated multiple columns for: #{item['name']}"
|
|
149
|
+
end
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
## Update Status Column
|
|
153
|
+
|
|
154
|
+
Change item status:
|
|
155
|
+
|
|
156
|
+
```ruby
|
|
157
|
+
response = client.column.change_value(
|
|
158
|
+
args: {
|
|
159
|
+
board_id: 1234567890,
|
|
160
|
+
item_id: 987654321,
|
|
161
|
+
column_id: "status",
|
|
162
|
+
value: JSON.generate({ label: "Done" })
|
|
163
|
+
}
|
|
164
|
+
)
|
|
165
|
+
|
|
166
|
+
if response.success?
|
|
167
|
+
puts "✓ Status updated to 'Done'"
|
|
168
|
+
end
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### Using Status Index
|
|
172
|
+
|
|
173
|
+
If you know the status label index:
|
|
174
|
+
|
|
175
|
+
```ruby
|
|
176
|
+
value = JSON.generate({ index: 1 })
|
|
177
|
+
|
|
178
|
+
response = client.column.change_value(
|
|
179
|
+
args: {
|
|
180
|
+
board_id: 1234567890,
|
|
181
|
+
item_id: 987654321,
|
|
182
|
+
column_id: "status",
|
|
183
|
+
value: value
|
|
184
|
+
}
|
|
185
|
+
)
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
## Update Date Column
|
|
189
|
+
|
|
190
|
+
Set dates with or without time:
|
|
191
|
+
|
|
192
|
+
### Date Only
|
|
193
|
+
|
|
194
|
+
```ruby
|
|
195
|
+
value = JSON.generate({ date: "2024-12-31" })
|
|
196
|
+
|
|
197
|
+
response = client.column.change_value(
|
|
198
|
+
args: {
|
|
199
|
+
board_id: 1234567890,
|
|
200
|
+
item_id: 987654321,
|
|
201
|
+
column_id: "date",
|
|
202
|
+
value: value
|
|
203
|
+
}
|
|
204
|
+
)
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
### Date and Time
|
|
208
|
+
|
|
209
|
+
```ruby
|
|
210
|
+
value = JSON.generate({
|
|
211
|
+
date: "2024-12-31",
|
|
212
|
+
time: "14:30:00"
|
|
213
|
+
})
|
|
214
|
+
|
|
215
|
+
response = client.column.change_value(
|
|
216
|
+
args: {
|
|
217
|
+
board_id: 1234567890,
|
|
218
|
+
item_id: 987654321,
|
|
219
|
+
column_id: "date",
|
|
220
|
+
value: value
|
|
221
|
+
}
|
|
222
|
+
)
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
### Clear Date
|
|
226
|
+
|
|
227
|
+
```ruby
|
|
228
|
+
value = JSON.generate({ date: nil, time: nil })
|
|
229
|
+
|
|
230
|
+
response = client.column.change_value(
|
|
231
|
+
args: {
|
|
232
|
+
board_id: 1234567890,
|
|
233
|
+
item_id: 987654321,
|
|
234
|
+
column_id: "date",
|
|
235
|
+
value: value
|
|
236
|
+
}
|
|
237
|
+
)
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
## Update People Column
|
|
241
|
+
|
|
242
|
+
Assign people to an item:
|
|
243
|
+
|
|
244
|
+
### Single Person
|
|
245
|
+
|
|
246
|
+
```ruby
|
|
247
|
+
value = JSON.generate({
|
|
248
|
+
personsAndTeams: [
|
|
249
|
+
{ id: 12345678, kind: "person" }
|
|
250
|
+
]
|
|
251
|
+
})
|
|
252
|
+
|
|
253
|
+
response = client.column.change_value(
|
|
254
|
+
args: {
|
|
255
|
+
board_id: 1234567890,
|
|
256
|
+
item_id: 987654321,
|
|
257
|
+
column_id: "people",
|
|
258
|
+
value: value
|
|
259
|
+
}
|
|
260
|
+
)
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
### Multiple People
|
|
264
|
+
|
|
265
|
+
```ruby
|
|
266
|
+
value = JSON.generate({
|
|
267
|
+
personsAndTeams: [
|
|
268
|
+
{ id: 12345678, kind: "person" },
|
|
269
|
+
{ id: 87654321, kind: "person" }
|
|
270
|
+
]
|
|
271
|
+
})
|
|
272
|
+
|
|
273
|
+
response = client.column.change_value(
|
|
274
|
+
args: {
|
|
275
|
+
board_id: 1234567890,
|
|
276
|
+
item_id: 987654321,
|
|
277
|
+
column_id: "people",
|
|
278
|
+
value: value
|
|
279
|
+
}
|
|
280
|
+
)
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
### Include Teams
|
|
284
|
+
|
|
285
|
+
```ruby
|
|
286
|
+
value = JSON.generate({
|
|
287
|
+
personsAndTeams: [
|
|
288
|
+
{ id: 12345678, kind: "person" },
|
|
289
|
+
{ id: 99999999, kind: "team" }
|
|
290
|
+
]
|
|
291
|
+
})
|
|
292
|
+
|
|
293
|
+
response = client.column.change_value(
|
|
294
|
+
args: {
|
|
295
|
+
board_id: 1234567890,
|
|
296
|
+
item_id: 987654321,
|
|
297
|
+
column_id: "people",
|
|
298
|
+
value: value
|
|
299
|
+
}
|
|
300
|
+
)
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
## Update Timeline Column
|
|
304
|
+
|
|
305
|
+
Set timeline start and end dates:
|
|
306
|
+
|
|
307
|
+
```ruby
|
|
308
|
+
value = JSON.generate({
|
|
309
|
+
from: "2024-01-01",
|
|
310
|
+
to: "2024-03-31"
|
|
311
|
+
})
|
|
312
|
+
|
|
313
|
+
response = client.column.change_value(
|
|
314
|
+
args: {
|
|
315
|
+
board_id: 1234567890,
|
|
316
|
+
item_id: 987654321,
|
|
317
|
+
column_id: "timeline",
|
|
318
|
+
value: value
|
|
319
|
+
}
|
|
320
|
+
)
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
## Update Dropdown Column
|
|
324
|
+
|
|
325
|
+
Set dropdown selection:
|
|
326
|
+
|
|
327
|
+
```ruby
|
|
328
|
+
value = JSON.generate({ labels: [123] }) # Label ID
|
|
329
|
+
|
|
330
|
+
response = client.column.change_value(
|
|
331
|
+
args: {
|
|
332
|
+
board_id: 1234567890,
|
|
333
|
+
item_id: 987654321,
|
|
334
|
+
column_id: "dropdown",
|
|
335
|
+
value: value
|
|
336
|
+
}
|
|
337
|
+
)
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
## Update Link Column
|
|
341
|
+
|
|
342
|
+
Add URL links:
|
|
343
|
+
|
|
344
|
+
```ruby
|
|
345
|
+
value = JSON.generate({
|
|
346
|
+
url: "https://example.com",
|
|
347
|
+
text: "Example Website"
|
|
348
|
+
})
|
|
349
|
+
|
|
350
|
+
response = client.column.change_value(
|
|
351
|
+
args: {
|
|
352
|
+
board_id: 1234567890,
|
|
353
|
+
item_id: 987654321,
|
|
354
|
+
column_id: "link",
|
|
355
|
+
value: value
|
|
356
|
+
}
|
|
357
|
+
)
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
## Bulk Update Items
|
|
361
|
+
|
|
362
|
+
Update multiple items efficiently:
|
|
363
|
+
|
|
364
|
+
```ruby
|
|
365
|
+
def bulk_update_status(client, board_id, item_ids, status_label)
|
|
366
|
+
updated_items = []
|
|
367
|
+
|
|
368
|
+
item_ids.each do |item_id|
|
|
369
|
+
response = client.column.change_value(
|
|
370
|
+
args: {
|
|
371
|
+
board_id: board_id,
|
|
372
|
+
item_id: item_id,
|
|
373
|
+
column_id: "status",
|
|
374
|
+
value: JSON.generate({ label: status_label })
|
|
375
|
+
}
|
|
376
|
+
)
|
|
377
|
+
|
|
378
|
+
if response.success?
|
|
379
|
+
item = response.body.dig("data", "change_column_value")
|
|
380
|
+
updated_items << item
|
|
381
|
+
puts "✓ Updated: #{item['name']}"
|
|
382
|
+
else
|
|
383
|
+
puts "✗ Failed to update item #{item_id}"
|
|
384
|
+
end
|
|
385
|
+
|
|
386
|
+
# Rate limiting: pause between requests
|
|
387
|
+
sleep(0.3)
|
|
388
|
+
end
|
|
389
|
+
|
|
390
|
+
updated_items
|
|
391
|
+
end
|
|
392
|
+
|
|
393
|
+
# Usage
|
|
394
|
+
item_ids = [987654321, 987654322, 987654323]
|
|
395
|
+
items = bulk_update_status(client, 1234567890, item_ids, "Done")
|
|
396
|
+
|
|
397
|
+
puts "\n✓ Updated #{items.length} items"
|
|
398
|
+
```
|
|
399
|
+
|
|
400
|
+
## Update with Create or Get
|
|
401
|
+
|
|
402
|
+
Update existing or create new column value:
|
|
403
|
+
|
|
404
|
+
```ruby
|
|
405
|
+
response = client.column.change_value(
|
|
406
|
+
args: {
|
|
407
|
+
board_id: 1234567890,
|
|
408
|
+
item_id: 987654321,
|
|
409
|
+
column_id: "status",
|
|
410
|
+
value: JSON.generate({ label: "Custom Status" }),
|
|
411
|
+
create_labels_if_missing: true
|
|
412
|
+
}
|
|
413
|
+
)
|
|
414
|
+
|
|
415
|
+
if response.success?
|
|
416
|
+
puts "✓ Status updated (label created if needed)"
|
|
417
|
+
end
|
|
418
|
+
```
|
|
419
|
+
|
|
420
|
+
## Customize Response Fields
|
|
421
|
+
|
|
422
|
+
Get detailed information about the updated item:
|
|
423
|
+
|
|
424
|
+
```ruby
|
|
425
|
+
response = client.column.change_value(
|
|
426
|
+
args: {
|
|
427
|
+
board_id: 1234567890,
|
|
428
|
+
item_id: 987654321,
|
|
429
|
+
column_id: "status",
|
|
430
|
+
value: JSON.generate({ label: "Done" })
|
|
431
|
+
},
|
|
432
|
+
select: [
|
|
433
|
+
"id",
|
|
434
|
+
"name",
|
|
435
|
+
"state",
|
|
436
|
+
{
|
|
437
|
+
column_values: ["id", "text", "type"]
|
|
438
|
+
}
|
|
439
|
+
]
|
|
440
|
+
)
|
|
441
|
+
|
|
442
|
+
if response.success?
|
|
443
|
+
item = response.body.dig("data", "change_column_value")
|
|
444
|
+
|
|
445
|
+
puts "Updated: #{item['name']}"
|
|
446
|
+
puts "Column Values:"
|
|
447
|
+
|
|
448
|
+
item["column_values"].each do |col_val|
|
|
449
|
+
next if col_val["text"].nil? || col_val["text"].empty?
|
|
450
|
+
puts " • #{col_val['id']}: #{col_val['text']}"
|
|
451
|
+
end
|
|
452
|
+
end
|
|
453
|
+
```
|
|
454
|
+
|
|
455
|
+
## Clear Column Value
|
|
456
|
+
|
|
457
|
+
Remove a column's value:
|
|
458
|
+
|
|
459
|
+
```ruby
|
|
460
|
+
response = client.column.change_value(
|
|
461
|
+
args: {
|
|
462
|
+
board_id: 1234567890,
|
|
463
|
+
item_id: 987654321,
|
|
464
|
+
column_id: "status",
|
|
465
|
+
value: JSON.generate({})
|
|
466
|
+
}
|
|
467
|
+
)
|
|
468
|
+
|
|
469
|
+
if response.success?
|
|
470
|
+
puts "✓ Column value cleared"
|
|
471
|
+
end
|
|
472
|
+
```
|
|
473
|
+
|
|
474
|
+
## Error Handling
|
|
475
|
+
|
|
476
|
+
Handle common update errors:
|
|
477
|
+
|
|
478
|
+
```ruby
|
|
479
|
+
def update_column_safe(client, board_id, item_id, column_id, value)
|
|
480
|
+
response = client.column.change_value(
|
|
481
|
+
args: {
|
|
482
|
+
board_id: board_id,
|
|
483
|
+
item_id: item_id,
|
|
484
|
+
column_id: column_id,
|
|
485
|
+
value: value
|
|
486
|
+
}
|
|
487
|
+
)
|
|
488
|
+
|
|
489
|
+
if response.success?
|
|
490
|
+
item = response.body.dig("data", "change_column_value")
|
|
491
|
+
puts "✓ Updated: #{item['name']}"
|
|
492
|
+
true
|
|
493
|
+
else
|
|
494
|
+
puts "✗ Failed to update column"
|
|
495
|
+
puts " Status: #{response.status}"
|
|
496
|
+
|
|
497
|
+
if response.body["errors"]
|
|
498
|
+
response.body["errors"].each do |error|
|
|
499
|
+
puts " Error: #{error['message']}"
|
|
500
|
+
end
|
|
501
|
+
end
|
|
502
|
+
|
|
503
|
+
false
|
|
504
|
+
end
|
|
505
|
+
rescue Monday::AuthorizationError
|
|
506
|
+
puts "✗ Invalid API token"
|
|
507
|
+
false
|
|
508
|
+
rescue Monday::InvalidRequestError => e
|
|
509
|
+
puts "✗ Invalid request: #{e.message}"
|
|
510
|
+
false
|
|
511
|
+
rescue Monday::Error => e
|
|
512
|
+
puts "✗ API error: #{e.message}"
|
|
513
|
+
false
|
|
514
|
+
end
|
|
515
|
+
|
|
516
|
+
# Usage
|
|
517
|
+
value = JSON.generate({ label: "Done" })
|
|
518
|
+
success = update_column_safe(
|
|
519
|
+
client,
|
|
520
|
+
1234567890,
|
|
521
|
+
987654321,
|
|
522
|
+
"status",
|
|
523
|
+
value
|
|
524
|
+
)
|
|
525
|
+
```
|
|
526
|
+
|
|
527
|
+
## Complete Example
|
|
528
|
+
|
|
529
|
+
Update multiple columns with full error handling:
|
|
530
|
+
|
|
531
|
+
```ruby
|
|
532
|
+
require "monday_ruby"
|
|
533
|
+
require "dotenv/load"
|
|
534
|
+
require "json"
|
|
535
|
+
|
|
536
|
+
Monday.configure do |config|
|
|
537
|
+
config.token = ENV["MONDAY_TOKEN"]
|
|
538
|
+
end
|
|
539
|
+
|
|
540
|
+
client = Monday::Client.new
|
|
541
|
+
|
|
542
|
+
# IMPORTANT: First, get your board's column IDs:
|
|
543
|
+
# See "Finding Column IDs" section at the top of this guide
|
|
544
|
+
|
|
545
|
+
# Update multiple columns at once
|
|
546
|
+
# ⚠️ Replace all column IDs with your board's actual column IDs
|
|
547
|
+
column_values = {
|
|
548
|
+
status: { label: "Working on it" }, # Your status column ID
|
|
549
|
+
text: "Updated task description", # Your text column ID
|
|
550
|
+
date4: { date: "2024-12-31", time: "17:00:00" }, # Your date column ID
|
|
551
|
+
people: { # Your people column ID
|
|
552
|
+
personsAndTeams: [
|
|
553
|
+
{ id: 12345678, kind: "person" } # Replace with actual user ID
|
|
554
|
+
]
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
response = client.column.change_multiple_values(
|
|
559
|
+
args: {
|
|
560
|
+
board_id: 1234567890,
|
|
561
|
+
item_id: 987654321,
|
|
562
|
+
column_values: JSON.generate(column_values)
|
|
563
|
+
},
|
|
564
|
+
select: [
|
|
565
|
+
"id",
|
|
566
|
+
"name",
|
|
567
|
+
"state",
|
|
568
|
+
{
|
|
569
|
+
column_values: ["id", "text", "type", "value"]
|
|
570
|
+
}
|
|
571
|
+
]
|
|
572
|
+
)
|
|
573
|
+
|
|
574
|
+
if response.success?
|
|
575
|
+
item = response.body.dig("data", "change_multiple_column_values")
|
|
576
|
+
|
|
577
|
+
puts "\n✓ Item Updated Successfully\n"
|
|
578
|
+
puts "#{'=' * 50}"
|
|
579
|
+
puts "Name: #{item['name']}"
|
|
580
|
+
puts "ID: #{item['id']}"
|
|
581
|
+
puts "State: #{item['state']}"
|
|
582
|
+
|
|
583
|
+
puts "\nUpdated Column Values:"
|
|
584
|
+
item["column_values"].each do |col_val|
|
|
585
|
+
next if col_val["text"].nil? || col_val["text"].empty?
|
|
586
|
+
puts " • #{col_val['id']}: #{col_val['text']} (#{col_val['type']})"
|
|
587
|
+
end
|
|
588
|
+
|
|
589
|
+
puts "#{'=' * 50}"
|
|
590
|
+
else
|
|
591
|
+
puts "\n✗ Failed to update item"
|
|
592
|
+
puts "Status code: #{response.status}"
|
|
593
|
+
|
|
594
|
+
if response.body["error_message"]
|
|
595
|
+
puts "Error: #{response.body['error_message']}"
|
|
596
|
+
end
|
|
597
|
+
end
|
|
598
|
+
```
|
|
599
|
+
|
|
600
|
+
## Update Based on Current Value
|
|
601
|
+
|
|
602
|
+
Read current value before updating:
|
|
603
|
+
|
|
604
|
+
```ruby
|
|
605
|
+
# First, get the current item
|
|
606
|
+
query_response = client.item.query(
|
|
607
|
+
args: { ids: [987654321] },
|
|
608
|
+
select: [
|
|
609
|
+
"id",
|
|
610
|
+
"name",
|
|
611
|
+
{
|
|
612
|
+
column_values: ["id", "text", "value"]
|
|
613
|
+
}
|
|
614
|
+
]
|
|
615
|
+
)
|
|
616
|
+
|
|
617
|
+
if query_response.success?
|
|
618
|
+
item = query_response.body.dig("data", "items", 0)
|
|
619
|
+
current_status = item["column_values"].find { |cv| cv["id"] == "status" }
|
|
620
|
+
|
|
621
|
+
# Update based on current value
|
|
622
|
+
new_status = if current_status&.dig("text") == "Working on it"
|
|
623
|
+
"Done"
|
|
624
|
+
else
|
|
625
|
+
"Working on it"
|
|
626
|
+
end
|
|
627
|
+
|
|
628
|
+
# Update the status
|
|
629
|
+
update_response = client.column.change_value(
|
|
630
|
+
args: {
|
|
631
|
+
board_id: 1234567890,
|
|
632
|
+
item_id: 987654321,
|
|
633
|
+
column_id: "status",
|
|
634
|
+
value: JSON.generate({ label: new_status })
|
|
635
|
+
}
|
|
636
|
+
)
|
|
637
|
+
|
|
638
|
+
if update_response.success?
|
|
639
|
+
puts "✓ Status toggled to: #{new_status}"
|
|
640
|
+
end
|
|
641
|
+
end
|
|
642
|
+
```
|
|
643
|
+
|
|
644
|
+
## Conditional Updates
|
|
645
|
+
|
|
646
|
+
Update only if condition is met:
|
|
647
|
+
|
|
648
|
+
```ruby
|
|
649
|
+
def update_if_status(client, board_id, item_id, current_status, new_column_values)
|
|
650
|
+
# Query current item
|
|
651
|
+
response = client.item.query(
|
|
652
|
+
args: { ids: [item_id] },
|
|
653
|
+
select: [
|
|
654
|
+
"id",
|
|
655
|
+
{
|
|
656
|
+
column_values: ["id", "text"]
|
|
657
|
+
}
|
|
658
|
+
]
|
|
659
|
+
)
|
|
660
|
+
|
|
661
|
+
return false unless response.success?
|
|
662
|
+
|
|
663
|
+
item = response.body.dig("data", "items", 0)
|
|
664
|
+
status = item["column_values"].find { |cv| cv["id"] == "status" }
|
|
665
|
+
|
|
666
|
+
# Check condition
|
|
667
|
+
return false unless status&.dig("text") == current_status
|
|
668
|
+
|
|
669
|
+
# Perform update
|
|
670
|
+
update_response = client.column.change_multiple_values(
|
|
671
|
+
args: {
|
|
672
|
+
board_id: board_id,
|
|
673
|
+
item_id: item_id,
|
|
674
|
+
column_values: JSON.generate(new_column_values)
|
|
675
|
+
}
|
|
676
|
+
)
|
|
677
|
+
|
|
678
|
+
update_response.success?
|
|
679
|
+
end
|
|
680
|
+
|
|
681
|
+
# Usage
|
|
682
|
+
updated = update_if_status(
|
|
683
|
+
client,
|
|
684
|
+
1234567890,
|
|
685
|
+
987654321,
|
|
686
|
+
"Working on it",
|
|
687
|
+
{ status: { label: "Done" }, text: "Completed successfully" }
|
|
688
|
+
)
|
|
689
|
+
|
|
690
|
+
puts updated ? "✓ Updated" : "✗ Condition not met"
|
|
691
|
+
```
|
|
692
|
+
|
|
693
|
+
## Next Steps
|
|
694
|
+
|
|
695
|
+
- [Query items](/guides/items/query)
|
|
696
|
+
- [Create items](/guides/items/create)
|
|
697
|
+
- [Update column metadata](/guides/columns/metadata)
|
|
698
|
+
- [Batch operations](/guides/advanced/batch)
|
|
699
|
+
- [Work with subitems](/guides/items/subitems)
|