0

Update a Location group

by
Published Oct 17, 2025

Updates an existing Location group by setting field values. Any fields not provided remain unchanged. New values for any arrays will replace the existing array.

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 a Location group
7
 * Updates an existing Location group by setting field values. Any fields not provided remain unchanged. New values for any arrays will replace the existing array.
8
 */
9
export async function main(
10
	auth: SageIntacct,
11
	key: string,
12
	body: {
13
		key?: string
14
		id?: string
15
		href?: string
16
		name?: string
17
		description?: string
18
		primaryContact?: { key?: string; id?: string; href?: string }
19
		groupType?: 'all' | 'specific'
20
		memberFilter?: {
21
			object?: string
22
			filters?:
23
				| { $eq?: {} }
24
				| { $ne?: {} }
25
				| { $lt?: {} }
26
				| { $lte?: {} }
27
				| { $gt?: {} }
28
				| { $gte?: {} }
29
				| { $in?: {} }
30
				| { $notIn?: {} }
31
				| { $contains?: {} }
32
				| { $notContains?: {} }
33
				| { $startsWith?: {} }
34
				| { $notStartsWith?: {} }
35
				| { $endsWith?: {} }
36
				| { $notEndsWith?: {} }[]
37
			filterExpression?: string
38
			orderBy?: {}[]
39
			size?: number
40
		} & {}
41
		groupMembers?: {
42
			key?: string
43
			id?: string
44
			href?: string
45
			location?: { key?: string; id?: string; name?: string; href?: string }
46
			locationGroup?: { key?: string; id?: string; href?: string }
47
			sortOrder?: number
48
			audit?: {
49
				createdDateTime?: string
50
				modifiedDateTime?: string
51
				createdBy?: string
52
				modifiedBy?: string
53
			}
54
		}[]
55
		isDimensionStructure?: false | true
56
		audit?: {
57
			createdDateTime?: string
58
			modifiedDateTime?: string
59
			createdBy?: string
60
			modifiedBy?: string
61
		}
62
	} & { id?: {} }
63
) {
64
	const url = new URL(
65
		`https://api.intacct.com/ia/api/v1/objects/company-config/location-group/${key}`
66
	)
67

68
	const response = await fetch(url, {
69
		method: 'PATCH',
70
		headers: {
71
			'Content-Type': 'application/json',
72
			Authorization: 'Bearer ' + auth.token
73
		},
74
		body: JSON.stringify(body)
75
	})
76
	if (!response.ok) {
77
		const text = await response.text()
78
		throw new Error(`${response.status} ${text}`)
79
	}
80
	return await response.json()
81
}
82