0

Update a standard task

by
Published Oct 17, 2025

Updates an existing standard task 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 standard task
7
 * Updates an existing standard task 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
		name?: string
17
		description?: string
18
		productionUnitDescription?: string
19
		status?: 'active' | 'inactive'
20
		item?: { key?: string; id?: string; name?: string; href?: string }
21
		isBillable?: false | true
22
		isMilestone?: false | true
23
		isUtilized?: false | true
24
		priority?: number
25
		timeType?: { key?: string; name?: string; href?: string }
26
		wbsCode?: string
27
		parent?: { key?: string; id?: string; name?: string; href?: string }
28
		class?: { id?: string; key?: string; name?: string; href?: string }
29
		standardCostTypes?: { key?: string; id?: string; href?: string }[]
30
		audit?: {
31
			createdDateTime?: string
32
			modifiedDateTime?: string
33
			createdBy?: string
34
			modifiedBy?: string
35
		}
36
	} & { id?: {} }
37
) {
38
	const url = new URL(`https://api.intacct.com/ia/api/v1/objects/construction/standard-task/${key}`)
39

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