0

Update a document sequence

by
Published Oct 17, 2025

Updates an existing document sequence 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 a document sequence
7
 * Updates an existing document sequence 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
		printTitle?: string
16
		type?: 'numeric' | 'alpha'
17
		fixedLength?: string
18
		fixedPrefix?: string
19
		prefixSeparator?: string
20
		fixedSuffix?: string
21
		suffixSeparator?: string
22
		startingNumber?: number
23
		endingNumber?: number
24
		nextNumber?: number
25
		startingSequence?: string
26
		endingSequence?: string
27
		nextSequence?: string
28
		whenModified?: string
29
		entity?: { key?: string; id?: string; name?: string; href?: string }
30
		rollover?: {
31
			isEnabled?: false | true
32
			enabledDate?: string
33
			fiscalYearAffixPosition?: 'none' | 'prefix' | 'suffix'
34
			separator?: string
35
			fiscalYears?: {
36
				key?: string
37
				id?: string
38
				href?: string
39
				documentSequence?: { key?: string; id?: string; href?: string }
40
				fiscalYear?: number
41
				nextNumber?: number
42
				nextSequence?: string
43
				audit?: {
44
					createdDateTime?: string
45
					modifiedDateTime?: string
46
					createdBy?: string
47
					modifiedBy?: string
48
				}
49
			}[]
50
		}
51
		status?: 'active' | 'inactive'
52
		href?: string
53
		audit?: {
54
			createdDateTime?: string
55
			modifiedDateTime?: string
56
			createdBy?: string
57
			modifiedBy?: string
58
		}
59
	} & { id?: {} }
60
) {
61
	const url = new URL(
62
		`https://api.intacct.com/ia/api/v1/objects/company-config/document-sequence/${key}`
63
	)
64

65
	const response = await fetch(url, {
66
		method: 'PATCH',
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