0

Update a statistical journal

by
Published Oct 17, 2025

Updates an existing statistical journal by setting field values. Any fields not provided remain unchanged. Permissions and other requirements SubscriptionGeneral Ledger User typeBusiness PermissionsEdit Statistical Journals

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 statistical journal
7
 * Updates an existing statistical journal by setting field values. Any fields not provided remain unchanged.
8

9

10
Permissions and other requirements
11

12
SubscriptionGeneral Ledger
13
User typeBusiness
14
PermissionsEdit Statistical Journals
15

16

17

18

19
 */
20
export async function main(
21
	auth: SageIntacct,
22
	key: string,
23
	body: {
24
		key?: string
25
		id?: string
26
		name?: string
27
		bookId?: string
28
		bookType?: 'accrual' | 'cash' | 'cashAndAccrual' | 'consolidation'
29
		disallowDirectPosting?: false | true
30
		status?: 'active' | 'inactive'
31
		audit?: {
32
			createdDateTime?: string
33
			modifiedDateTime?: string
34
			createdBy?: string
35
			modifiedBy?: string
36
		}
37
		href?: string
38
	} & { id?: {} }
39
) {
40
	const url = new URL(
41
		`https://api.intacct.com/ia/api/v1/objects/general-ledger/statistical-journal/${key}`
42
	)
43

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