0

Create a Location group

by
Published Oct 17, 2025

Creates a new Location group.

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

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