0

Update a unit of measure group

by
Published Oct 17, 2025

Updates an existing unit of measure group by setting field values. Any fields not provided remain unchanged. Permissions and other requirements SubscriptionInventory Control, Order Entry, or Purchasing ConfigurationInventory Control, Order Entry, or Purchasing must be enabled for custom units of measure to add, edit, or delete unit of measure groups. User typeBusiness PermissionsList, View, Edit Unit of Measure groups

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

9

10
Permissions and other requirements
11

12
SubscriptionInventory Control, Order Entry, or Purchasing
13
ConfigurationInventory Control, Order Entry, or Purchasing must be enabled for custom units of measure to add, edit, or delete unit of measure groups.
14
User typeBusiness
15
PermissionsList, View, Edit Unit of Measure groups
16

17

18

19

20
 */
21
export async function main(
22
	auth: SageIntacct,
23
	key: string,
24
	body: {
25
		key?: string
26
		id?: string
27
		baseUnit?: string
28
		abbreviation?: string
29
		isSystemGenerated?: false | true
30
		defaults?: {
31
			inventory?: { key?: string; id?: string; href?: string }
32
			purchaseOrder?: { key?: string; id?: string; href?: string }
33
			orderEntry?: { key?: string; id?: string; href?: string }
34
		}
35
		unitsOfMeasure?: {
36
			key?: string
37
			id?: string
38
			abbreviation?: string
39
			numberOfDecimalPlaces?: number
40
			isBase?: false | true
41
			parent?: { key?: string; id?: string; href?: string }
42
			conversionFactor?: number
43
			href?: string
44
			audit?: {
45
				createdDateTime?: string
46
				modifiedDateTime?: string
47
				createdBy?: string
48
				modifiedBy?: string
49
			}
50
		}[]
51
		href?: string
52
		audit?: {
53
			createdDateTime?: string
54
			modifiedDateTime?: string
55
			createdBy?: string
56
			modifiedBy?: string
57
		}
58
	} & { id?: {} }
59
) {
60
	const url = new URL(
61
		`https://api.intacct.com/ia/api/v1/objects/inventory-control/unit-of-measure-group/${key}`
62
	)
63

64
	const response = await fetch(url, {
65
		method: 'PATCH',
66
		headers: {
67
			'Content-Type': 'application/json',
68
			Authorization: 'Bearer ' + auth.token
69
		},
70
		body: JSON.stringify(body)
71
	})
72
	if (!response.ok) {
73
		const text = await response.text()
74
		throw new Error(`${response.status} ${text}`)
75
	}
76
	return await response.json()
77
}
78