0

Update an item cross reference

by
Published Oct 17, 2025

Updates an existing item cross reference by setting field values. Any fields not provided remain unchanged. Permissions and other requirements SubscriptionInventory Control, Order Entry User typeBusiness PermissionsEdit, List, View Item cross references

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

9

10
Permissions and other requirements
11

12
SubscriptionInventory Control, Order Entry
13
User typeBusiness
14
PermissionsEdit, List, View Item cross references
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
		href?: string
27
		referenceType?: 'customer' | 'vendor' | 'substitute' | 'upgrade' | 'downgrade' | 'complement'
28
		itemAliasId?: string
29
		itemAliasDescription?: string
30
		unitOfMeasure?: { key?: string; id?: string; href?: string }
31
		referenceTypeContext?: 'internal' | 'external'
32
		alternateItem?: { key?: string; id?: string; name?: string; href?: string }
33
		customer?: { key?: string; id?: string; name?: string; href?: string }
34
		item?: { key?: string; id?: string; name?: string; href?: string }
35
		vendor?: { key?: string; id?: string; name?: string; href?: string }
36
		audit?: {
37
			createdDateTime?: string
38
			modifiedDateTime?: string
39
			createdBy?: string
40
			modifiedBy?: string
41
		}
42
	} & { referenceType?: {} }
43
) {
44
	const url = new URL(
45
		`https://api.intacct.com/ia/api/v1/objects/inventory-control/item-cross-reference/${key}`
46
	)
47

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