0

Update a unit of measure

by
Published Oct 17, 2025

Updates an existing custom unit of measure by setting field values. Any fields not provided remain unchanged. Units of measure already in use cannot be modified. 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 units of measure. User typeBusiness PermissionsList, View, Edit Units of Measure

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
7
 * Updates an existing custom unit of measure by setting field values. Any fields not provided remain unchanged. Units of measure already in use cannot be modified.
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 units of measure.
14
User typeBusiness
15
PermissionsList, View, Edit Units of Measure
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
		abbreviation?: string
28
		numberOfDecimalPlaces?: number
29
		isBase?: false | true
30
		parent?: { key?: string; id?: string; href?: string }
31
		conversionFactor?: number
32
		href?: string
33
		audit?: {
34
			createdDateTime?: string
35
			modifiedDateTime?: string
36
			createdBy?: string
37
			modifiedBy?: string
38
		}
39
	} & { id?: {} }
40
) {
41
	const url = new URL(
42
		`https://api.intacct.com/ia/api/v1/objects/inventory-control/unit-of-measure/${key}`
43
	)
44

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