0

Update a customer item cross reference

by
Published Oct 17, 2025

Updates an existing customer item cross reference 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 customer item cross reference
7
 * Updates an existing customer item cross reference 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
		customer?: { key?: string; id?: string; name?: string; href?: string }
17
		item?: { key?: string; id?: string; name?: string; href?: string }
18
		referenceType?: 'customer'
19
		itemAliasId?: string
20
		itemAliasDescription?: string
21
		unit?: string
22
		referenceTypeContext?: 'internal' | 'external'
23
		audit?: {
24
			createdDateTime?: string
25
			modifiedDateTime?: string
26
			createdBy?: string
27
			modifiedBy?: string
28
		}
29
	} & { id?: {} }
30
) {
31
	const url = new URL(
32
		`https://api.intacct.com/ia/api/v1/objects/accounts-receivable/customer-item-cross-reference/${key}`
33
	)
34

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