0

Update a change request status

by
Published Oct 17, 2025

Updates an existing change request status 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 change request status
7
 * Updates an existing change request status 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
		href?: string
16
		workflowType?:
17
			| 'none'
18
			| 'original'
19
			| 'revision'
20
			| 'forecast'
21
			| 'approvedChange'
22
			| 'pendingChange'
23
			| 'other'
24
		status?: 'active' | 'inactive'
25
		audit?: {
26
			createdDateTime?: string
27
			modifiedDateTime?: string
28
			createdBy?: string
29
			modifiedBy?: string
30
		}
31
	} & { id?: {} }
32
) {
33
	const url = new URL(
34
		`https://api.intacct.com/ia/api/v1/objects/construction/change-request-status/${key}`
35
	)
36

37
	const response = await fetch(url, {
38
		method: 'PATCH',
39
		headers: {
40
			'Content-Type': 'application/json',
41
			Authorization: 'Bearer ' + auth.token
42
		},
43
		body: JSON.stringify(body)
44
	})
45
	if (!response.ok) {
46
		const text = await response.text()
47
		throw new Error(`${response.status} ${text}`)
48
	}
49
	return await response.json()
50
}
51