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,483 @@
|
|
|
1
|
+
# Manage Subitems
|
|
2
|
+
|
|
3
|
+
Work with subitems (child items) to break down tasks into smaller, manageable pieces.
|
|
4
|
+
|
|
5
|
+
## What are Subitems?
|
|
6
|
+
|
|
7
|
+
Subitems are child items that live under a parent item. They help you:
|
|
8
|
+
- Break down large tasks into smaller steps
|
|
9
|
+
- Track progress at a more granular level
|
|
10
|
+
- Organize work hierarchically
|
|
11
|
+
|
|
12
|
+
## Create a Subitem
|
|
13
|
+
|
|
14
|
+
Add a subitem to an existing item:
|
|
15
|
+
|
|
16
|
+
```ruby
|
|
17
|
+
require "monday_ruby"
|
|
18
|
+
|
|
19
|
+
Monday.configure do |config|
|
|
20
|
+
config.token = ENV["MONDAY_TOKEN"]
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
client = Monday::Client.new
|
|
24
|
+
|
|
25
|
+
response = client.subitem.create(
|
|
26
|
+
args: {
|
|
27
|
+
parent_item_id: 987654321, # The parent item ID
|
|
28
|
+
item_name: "Subitem Task"
|
|
29
|
+
}
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
if response.success?
|
|
33
|
+
subitem = response.body.dig("data", "create_subitem")
|
|
34
|
+
puts "✓ Created subitem: #{subitem['name']}"
|
|
35
|
+
puts " ID: #{subitem['id']}"
|
|
36
|
+
puts " Created: #{subitem['created_at']}"
|
|
37
|
+
else
|
|
38
|
+
puts "✗ Failed to create subitem"
|
|
39
|
+
end
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
**Output:**
|
|
43
|
+
```
|
|
44
|
+
✓ Created subitem: Subitem Task
|
|
45
|
+
ID: 7092811738
|
|
46
|
+
Created: 2024-07-25T04:00:04Z
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Create Multiple Subitems
|
|
50
|
+
|
|
51
|
+
Break down a task into multiple steps:
|
|
52
|
+
|
|
53
|
+
```ruby
|
|
54
|
+
parent_item_id = 987654321
|
|
55
|
+
subtasks = [
|
|
56
|
+
"Design mockups",
|
|
57
|
+
"Get feedback",
|
|
58
|
+
"Revise design",
|
|
59
|
+
"Final approval"
|
|
60
|
+
]
|
|
61
|
+
|
|
62
|
+
created_subitems = []
|
|
63
|
+
|
|
64
|
+
subtasks.each do |task_name|
|
|
65
|
+
response = client.subitem.create(
|
|
66
|
+
args: {
|
|
67
|
+
parent_item_id: parent_item_id,
|
|
68
|
+
item_name: task_name
|
|
69
|
+
}
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
if response.success?
|
|
73
|
+
subitem = response.body.dig("data", "create_subitem")
|
|
74
|
+
created_subitems << subitem
|
|
75
|
+
puts "✓ Created: #{subitem['name']}"
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
sleep(0.3) # Rate limiting
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
puts "\nCreated #{created_subitems.length} subitems"
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
**Output:**
|
|
85
|
+
```
|
|
86
|
+
✓ Created: Design mockups
|
|
87
|
+
✓ Created: Get feedback
|
|
88
|
+
✓ Created: Revise design
|
|
89
|
+
✓ Created: Final approval
|
|
90
|
+
|
|
91
|
+
Created 4 subitems
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Create Subitem with Column Values
|
|
95
|
+
|
|
96
|
+
Set column values when creating a subitem:
|
|
97
|
+
|
|
98
|
+
```ruby
|
|
99
|
+
# Note: Replace column IDs with your board's actual column IDs
|
|
100
|
+
response = client.subitem.create(
|
|
101
|
+
args: {
|
|
102
|
+
parent_item_id: 987654321,
|
|
103
|
+
item_name: "Design Phase",
|
|
104
|
+
column_values: {
|
|
105
|
+
status: { # ⚠️ Your status column ID
|
|
106
|
+
label: "Working on it"
|
|
107
|
+
},
|
|
108
|
+
date4: { # ⚠️ Your date column ID
|
|
109
|
+
date: "2024-12-15"
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
)
|
|
114
|
+
|
|
115
|
+
if response.success?
|
|
116
|
+
subitem = response.body.dig("data", "create_subitem")
|
|
117
|
+
puts "✓ Subitem created with column values"
|
|
118
|
+
end
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
::: 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>Finding Column IDs</span>
|
|
122
|
+
Subitems live on a subitems board. Query that board's columns to get the correct column IDs. See [Create Items guide](/guides/items/create#finding-column-ids) for details.
|
|
123
|
+
:::
|
|
124
|
+
|
|
125
|
+
## Query Subitems
|
|
126
|
+
|
|
127
|
+
Retrieve subitems for a parent item:
|
|
128
|
+
|
|
129
|
+
```ruby
|
|
130
|
+
response = client.subitem.query(
|
|
131
|
+
args: { ids: [987654321] } # Parent item ID
|
|
132
|
+
)
|
|
133
|
+
|
|
134
|
+
if response.success?
|
|
135
|
+
items = response.body.dig("data", "items")
|
|
136
|
+
subitems = items.first&.dig("subitems") || []
|
|
137
|
+
|
|
138
|
+
puts "Found #{subitems.length} subitems:"
|
|
139
|
+
subitems.each do |subitem|
|
|
140
|
+
puts " • #{subitem['name']} (ID: #{subitem['id']})"
|
|
141
|
+
end
|
|
142
|
+
end
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
## Query with Custom Fields
|
|
146
|
+
|
|
147
|
+
Get additional details about subitems:
|
|
148
|
+
|
|
149
|
+
```ruby
|
|
150
|
+
response = client.subitem.query(
|
|
151
|
+
args: { ids: [987654321] },
|
|
152
|
+
select: [
|
|
153
|
+
"id",
|
|
154
|
+
"name",
|
|
155
|
+
"created_at",
|
|
156
|
+
"state",
|
|
157
|
+
{
|
|
158
|
+
column_values: ["id", "text", "type"]
|
|
159
|
+
}
|
|
160
|
+
]
|
|
161
|
+
)
|
|
162
|
+
|
|
163
|
+
if response.success?
|
|
164
|
+
items = response.body.dig("data", "items")
|
|
165
|
+
subitems = items.first&.dig("subitems") || []
|
|
166
|
+
|
|
167
|
+
subitems.each do |subitem|
|
|
168
|
+
puts "\n#{subitem['name']}"
|
|
169
|
+
puts " ID: #{subitem['id']}"
|
|
170
|
+
puts " State: #{subitem['state']}"
|
|
171
|
+
puts " Created: #{subitem['created_at']}"
|
|
172
|
+
|
|
173
|
+
if subitem["column_values"]
|
|
174
|
+
puts " Column Values:"
|
|
175
|
+
subitem["column_values"].each do |col|
|
|
176
|
+
next if col["text"].nil? || col["text"].empty?
|
|
177
|
+
puts " • #{col['id']}: #{col['text']}"
|
|
178
|
+
end
|
|
179
|
+
end
|
|
180
|
+
end
|
|
181
|
+
end
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
## Query Multiple Parent Items
|
|
185
|
+
|
|
186
|
+
Get subitems for multiple items at once:
|
|
187
|
+
|
|
188
|
+
```ruby
|
|
189
|
+
parent_item_ids = [987654321, 987654322, 987654323]
|
|
190
|
+
|
|
191
|
+
response = client.subitem.query(
|
|
192
|
+
args: { ids: parent_item_ids },
|
|
193
|
+
select: ["id", "name", "created_at"]
|
|
194
|
+
)
|
|
195
|
+
|
|
196
|
+
if response.success?
|
|
197
|
+
items = response.body.dig("data", "items")
|
|
198
|
+
|
|
199
|
+
items.each do |item|
|
|
200
|
+
subitems = item["subitems"] || []
|
|
201
|
+
puts "\nParent: Item #{item['id']}"
|
|
202
|
+
puts " Subitems: #{subitems.length}"
|
|
203
|
+
|
|
204
|
+
subitems.each do |subitem|
|
|
205
|
+
puts " • #{subitem['name']}"
|
|
206
|
+
end
|
|
207
|
+
end
|
|
208
|
+
end
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
## Update Subitem Values
|
|
212
|
+
|
|
213
|
+
Subitems are regular items, so use the item/column update methods:
|
|
214
|
+
|
|
215
|
+
```ruby
|
|
216
|
+
# Update a subitem's column value
|
|
217
|
+
subitem_id = 7092811738
|
|
218
|
+
|
|
219
|
+
response = client.column.change_value(
|
|
220
|
+
args: {
|
|
221
|
+
board_id: 1234567890, # The subitems board ID
|
|
222
|
+
item_id: subitem_id,
|
|
223
|
+
column_id: "status", # ⚠️ Your status column ID
|
|
224
|
+
value: JSON.generate({ label: "Done" })
|
|
225
|
+
}
|
|
226
|
+
)
|
|
227
|
+
|
|
228
|
+
if response.success?
|
|
229
|
+
puts "✓ Subitem updated"
|
|
230
|
+
end
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
::: 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>Subitems Board ID</span>
|
|
234
|
+
To update subitem values, you need the **subitems board ID**, not the parent board ID. Query the parent item to find the subitems board ID.
|
|
235
|
+
:::
|
|
236
|
+
|
|
237
|
+
## Get Subitems Board ID
|
|
238
|
+
|
|
239
|
+
Find the board ID for subitems:
|
|
240
|
+
|
|
241
|
+
```ruby
|
|
242
|
+
# Query the parent item to get subitems board reference
|
|
243
|
+
response = client.item.query(
|
|
244
|
+
args: { ids: [987654321] },
|
|
245
|
+
select: [
|
|
246
|
+
"id",
|
|
247
|
+
"name",
|
|
248
|
+
{
|
|
249
|
+
board: ["id", "name"]
|
|
250
|
+
}
|
|
251
|
+
]
|
|
252
|
+
)
|
|
253
|
+
|
|
254
|
+
if response.success?
|
|
255
|
+
item = response.body.dig("data", "items", 0)
|
|
256
|
+
board = item.dig("board")
|
|
257
|
+
|
|
258
|
+
puts "Item: #{item['name']}"
|
|
259
|
+
puts "Board: #{board['name']} (ID: #{board['id']})"
|
|
260
|
+
puts "\nSubitems will be on a related subitems board"
|
|
261
|
+
end
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
## Delete Subitems
|
|
265
|
+
|
|
266
|
+
Subitems are items, so use the item delete method:
|
|
267
|
+
|
|
268
|
+
```ruby
|
|
269
|
+
subitem_id = 7092811738
|
|
270
|
+
|
|
271
|
+
response = client.item.delete(subitem_id)
|
|
272
|
+
|
|
273
|
+
if response.success?
|
|
274
|
+
puts "✓ Subitem deleted"
|
|
275
|
+
end
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
## Complete Example
|
|
279
|
+
|
|
280
|
+
Create and manage a project with subitems:
|
|
281
|
+
|
|
282
|
+
```ruby
|
|
283
|
+
require "monday_ruby"
|
|
284
|
+
require "dotenv/load"
|
|
285
|
+
|
|
286
|
+
Monday.configure do |config|
|
|
287
|
+
config.token = ENV["MONDAY_TOKEN"]
|
|
288
|
+
end
|
|
289
|
+
|
|
290
|
+
client = Monday::Client.new
|
|
291
|
+
|
|
292
|
+
# First, create a parent item
|
|
293
|
+
parent_response = client.item.create(
|
|
294
|
+
args: {
|
|
295
|
+
board_id: 1234567890,
|
|
296
|
+
item_name: "Website Redesign Project"
|
|
297
|
+
}
|
|
298
|
+
)
|
|
299
|
+
|
|
300
|
+
parent_item = parent_response.body.dig("data", "create_item")
|
|
301
|
+
puts "✓ Created parent item: #{parent_item['name']}"
|
|
302
|
+
|
|
303
|
+
# Define project phases as subitems
|
|
304
|
+
phases = [
|
|
305
|
+
"Research & Planning",
|
|
306
|
+
"Design Mockups",
|
|
307
|
+
"Development",
|
|
308
|
+
"Testing & QA",
|
|
309
|
+
"Launch"
|
|
310
|
+
]
|
|
311
|
+
|
|
312
|
+
# Create subitems for each phase
|
|
313
|
+
puts "\nCreating project phases..."
|
|
314
|
+
phases.each do |phase_name|
|
|
315
|
+
response = client.subitem.create(
|
|
316
|
+
args: {
|
|
317
|
+
parent_item_id: parent_item["id"],
|
|
318
|
+
item_name: phase_name
|
|
319
|
+
},
|
|
320
|
+
select: ["id", "name", "created_at"]
|
|
321
|
+
)
|
|
322
|
+
|
|
323
|
+
if response.success?
|
|
324
|
+
subitem = response.body.dig("data", "create_subitem")
|
|
325
|
+
puts " ✓ #{subitem['name']}"
|
|
326
|
+
end
|
|
327
|
+
|
|
328
|
+
sleep(0.3)
|
|
329
|
+
end
|
|
330
|
+
|
|
331
|
+
# Query all subitems
|
|
332
|
+
puts "\nQuerying created subitems..."
|
|
333
|
+
query_response = client.subitem.query(
|
|
334
|
+
args: { ids: [parent_item["id"]] },
|
|
335
|
+
select: ["id", "name"]
|
|
336
|
+
)
|
|
337
|
+
|
|
338
|
+
if query_response.success?
|
|
339
|
+
items = query_response.body.dig("data", "items")
|
|
340
|
+
subitems = items.first&.dig("subitems") || []
|
|
341
|
+
|
|
342
|
+
puts "\n" + "=" * 50
|
|
343
|
+
puts "Project: #{parent_item['name']}"
|
|
344
|
+
puts "Phases: #{subitems.length}"
|
|
345
|
+
puts "\nSubitems:"
|
|
346
|
+
subitems.each_with_index do |subitem, index|
|
|
347
|
+
puts " #{index + 1}. #{subitem['name']} (ID: #{subitem['id']})"
|
|
348
|
+
end
|
|
349
|
+
puts "=" * 50
|
|
350
|
+
end
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
**Output:**
|
|
354
|
+
```
|
|
355
|
+
✓ Created parent item: Website Redesign Project
|
|
356
|
+
|
|
357
|
+
Creating project phases...
|
|
358
|
+
✓ Research & Planning
|
|
359
|
+
✓ Design Mockups
|
|
360
|
+
✓ Development
|
|
361
|
+
✓ Testing & QA
|
|
362
|
+
✓ Launch
|
|
363
|
+
|
|
364
|
+
Querying created subitems...
|
|
365
|
+
|
|
366
|
+
==================================================
|
|
367
|
+
Project: Website Redesign Project
|
|
368
|
+
Phases: 5
|
|
369
|
+
|
|
370
|
+
Subitems:
|
|
371
|
+
1. Research & Planning (ID: 7092811740)
|
|
372
|
+
2. Design Mockups (ID: 7092811741)
|
|
373
|
+
3. Development (ID: 7092811742)
|
|
374
|
+
4. Testing & QA (ID: 7092811743)
|
|
375
|
+
5. Launch (ID: 7092811744)
|
|
376
|
+
==================================================
|
|
377
|
+
```
|
|
378
|
+
|
|
379
|
+
## Count Subitems
|
|
380
|
+
|
|
381
|
+
Count how many subitems an item has:
|
|
382
|
+
|
|
383
|
+
```ruby
|
|
384
|
+
response = client.subitem.query(
|
|
385
|
+
args: { ids: [987654321] },
|
|
386
|
+
select: ["id", "name"]
|
|
387
|
+
)
|
|
388
|
+
|
|
389
|
+
if response.success?
|
|
390
|
+
items = response.body.dig("data", "items")
|
|
391
|
+
subitems = items.first&.dig("subitems") || []
|
|
392
|
+
|
|
393
|
+
puts "This item has #{subitems.length} subitems"
|
|
394
|
+
end
|
|
395
|
+
```
|
|
396
|
+
|
|
397
|
+
## Filter Parent Items by Subitem Count
|
|
398
|
+
|
|
399
|
+
Find items with or without subitems:
|
|
400
|
+
|
|
401
|
+
```ruby
|
|
402
|
+
# Query multiple items
|
|
403
|
+
response = client.item.query(
|
|
404
|
+
args: { ids: [987654321, 987654322, 987654323] },
|
|
405
|
+
select: [
|
|
406
|
+
"id",
|
|
407
|
+
"name",
|
|
408
|
+
{
|
|
409
|
+
subitems: ["id"]
|
|
410
|
+
}
|
|
411
|
+
]
|
|
412
|
+
)
|
|
413
|
+
|
|
414
|
+
if response.success?
|
|
415
|
+
items = response.body.dig("data", "items")
|
|
416
|
+
|
|
417
|
+
items_with_subitems = items.select do |item|
|
|
418
|
+
subitems = item["subitems"] || []
|
|
419
|
+
subitems.length > 0
|
|
420
|
+
end
|
|
421
|
+
|
|
422
|
+
puts "Items with subitems: #{items_with_subitems.length}"
|
|
423
|
+
items_with_subitems.each do |item|
|
|
424
|
+
subitem_count = item["subitems"].length
|
|
425
|
+
puts " • #{item['name']} (#{subitem_count} subitems)"
|
|
426
|
+
end
|
|
427
|
+
end
|
|
428
|
+
```
|
|
429
|
+
|
|
430
|
+
## Error Handling
|
|
431
|
+
|
|
432
|
+
Handle common subitem errors:
|
|
433
|
+
|
|
434
|
+
```ruby
|
|
435
|
+
def create_subitem_safe(client, parent_item_id, subitem_name)
|
|
436
|
+
response = client.subitem.create(
|
|
437
|
+
args: {
|
|
438
|
+
parent_item_id: parent_item_id,
|
|
439
|
+
item_name: subitem_name
|
|
440
|
+
}
|
|
441
|
+
)
|
|
442
|
+
|
|
443
|
+
if response.success?
|
|
444
|
+
subitem = response.body.dig("data", "create_subitem")
|
|
445
|
+
puts "✓ Created: #{subitem['name']}"
|
|
446
|
+
subitem["id"]
|
|
447
|
+
else
|
|
448
|
+
puts "✗ Failed to create subitem"
|
|
449
|
+
nil
|
|
450
|
+
end
|
|
451
|
+
rescue Monday::AuthorizationError
|
|
452
|
+
puts "✗ Invalid API token"
|
|
453
|
+
nil
|
|
454
|
+
rescue Monday::Error => e
|
|
455
|
+
puts "✗ API error: #{e.message}"
|
|
456
|
+
nil
|
|
457
|
+
end
|
|
458
|
+
|
|
459
|
+
# Usage
|
|
460
|
+
subitem_id = create_subitem_safe(client, 987654321, "New Subitem")
|
|
461
|
+
```
|
|
462
|
+
|
|
463
|
+
## Best Practices
|
|
464
|
+
|
|
465
|
+
### Use Subitems For
|
|
466
|
+
|
|
467
|
+
- Breaking down large tasks into steps
|
|
468
|
+
- Tracking sub-components of a feature
|
|
469
|
+
- Managing checklist items
|
|
470
|
+
- Organizing hierarchical work
|
|
471
|
+
|
|
472
|
+
### Avoid Subitems For
|
|
473
|
+
|
|
474
|
+
- Deep nesting (subitems can't have their own subitems)
|
|
475
|
+
- Unrelated tasks (use groups or separate items instead)
|
|
476
|
+
- Cross-board relationships (use connect boards column)
|
|
477
|
+
|
|
478
|
+
## Next Steps
|
|
479
|
+
|
|
480
|
+
- [Create items](/guides/items/create)
|
|
481
|
+
- [Query items](/guides/items/query)
|
|
482
|
+
- [Update column values](/guides/items/update)
|
|
483
|
+
- [Work with groups](/guides/boards/query#query-with-groups)
|