0

Create a department group

by
Published Oct 17, 2025

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

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