0

Update an account allocation group

by
Published Oct 17, 2025

Updates an existing account allocation group by setting field values. Any fields not provided remain unchanged.

Script sage_intacct Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type SageIntacct = {
3
	token: string
4
}
5
/**
6
 * Update an account allocation group
7
 * Updates an existing account allocation group by setting field values. Any fields not provided remain unchanged.
8
 */
9
export async function main(
10
	auth: SageIntacct,
11
	key: string,
12
	body: {
13
		key?: string
14
		id?: string
15
		name?: string
16
		description?: string
17
		errorProcessingMethod?: 'stop' | 'skipAndContinue'
18
		lines?: {
19
			key?: string
20
			id?: string
21
			glAccountAllocation?: {
22
				key?: string
23
				id?: string
24
				name?: string
25
				href?: string
26
			}
27
			glAccountAllocationGroup?: { key?: string; id?: string; href?: string }
28
			status?: 'active' | 'inactive'
29
			audit?: {
30
				createdDateTime?: string
31
				modifiedDateTime?: string
32
				createdBy?: string
33
				modifiedBy?: string
34
			}
35
		}[]
36
		status?: 'active' | 'inactive'
37
		audit?: {
38
			createdDateTime?: string
39
			modifiedDateTime?: string
40
			createdBy?: string
41
			modifiedBy?: string
42
		}
43
		href?: string
44
	} & { id?: {} }
45
) {
46
	const url = new URL(
47
		`https://api.intacct.com/ia/api/v1/objects/general-ledger/account-allocation-group/${key}`
48
	)
49

50
	const response = await fetch(url, {
51
		method: 'PATCH',
52
		headers: {
53
			'Content-Type': 'application/json',
54
			Authorization: 'Bearer ' + auth.token
55
		},
56
		body: JSON.stringify(body)
57
	})
58
	if (!response.ok) {
59
		const text = await response.text()
60
		throw new Error(`${response.status} ${text}`)
61
	}
62
	return await response.json()
63
}
64