0

Update a timesheet line

by
Published Oct 17, 2025

Updates an existing timesheet line by setting field values. Any fields not provided remain unchanged. Whether approvals are turned on for a company, and where a timesheet is in the approval process determines if a timesheet line can be edited. Permissions and other requirements SubscriptionTime & Expenses User typeBusiness, Project Manager, or Employee PermissionsEdit timesheets

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 timesheet line
7
 * Updates an existing timesheet line by setting field values. Any fields not provided remain unchanged. Whether approvals are turned on for a company, and where a timesheet is in the approval process determines if a timesheet line can be edited.
8

9

10
Permissions and other requirements
11

12
SubscriptionTime & Expenses
13
User typeBusiness, Project Manager, or Employee
14
PermissionsEdit timesheets
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
		timesheet?: { key?: string; id?: string; href?: string }
28
		entryDate?: string
29
		quantity?: number
30
		lineNumber?: number
31
		description?: string
32
		notes?: string
33
		state?:
34
			| 'submitted'
35
			| 'approved'
36
			| 'partiallyApproved'
37
			| 'declined'
38
			| 'draft'
39
			| 'saved'
40
			| 'readyForApproval'
41
		timeType?: { key?: string; id?: string; href?: string }
42
		isBillable?: false | true
43
		isBilled?: 'true' | 'false' | 'partial'
44
		statisticalJournal?: { key?: string; id?: string; href?: string }
45
		billableUtilizedGLAccount?: { key?: string; id?: string; href?: string }
46
		nonBillableUtilizedGLAccount?: { key?: string; id?: string; href?: string }
47
		billableNonUtilizedGLAccount?: { key?: string; id?: string; href?: string }
48
		nonBillableNonUtilizedGLAccount?: {
49
			key?: string
50
			id?: string
51
			href?: string
52
		}
53
		hours?: {
54
			billable?: number
55
			nonBillable?: number
56
			approved?: number
57
			approvedBillable?: number
58
			approvedNonBillable?: number
59
			utilized?: number
60
			nonUtilized?: number
61
			approvedUtilized?: number
62
			approvedNonUtilized?: number
63
		}
64
		externalPayroll?: {
65
			costRate?: number
66
			billingRate?: number
67
			amount?: string
68
			employerTaxes?: number
69
			fringes?: number
70
			cashFringes?: number
71
		}
72
		laborClass?: { key?: string; id?: string; name?: string; href?: string }
73
		laborShift?: { key?: string; id?: string; name?: string; href?: string }
74
		laborUnion?: { key?: string; id?: string; name?: string; href?: string }
75
		dimensions?: {
76
			location?: { key?: string; id?: string; name?: string; href?: string }
77
			department?: { key?: string; id?: string; name?: string; href?: string }
78
			employee?: { key?: string; id?: string; name?: string; href?: string }
79
			project?: { key?: string; id?: string; name?: string; href?: string }
80
			customer?: { key?: string; id?: string; name?: string; href?: string }
81
			vendor?: { key?: string; id?: string; name?: string; href?: string }
82
			item?: { key?: string; id?: string; name?: string; href?: string }
83
			warehouse?: { key?: string; id?: string; name?: string; href?: string }
84
			class?: { key?: string; id?: string; name?: string; href?: string }
85
			task?: { id?: string; key?: string; name?: string; href?: string }
86
			costType?: { id?: string; key?: string; name?: string; href?: string }
87
			asset?: { id?: string; key?: string; name?: string; href?: string }
88
			contract?: { id?: string; key?: string; name?: string; href?: string }
89
			affiliateEntity?: {
90
				key?: string
91
				id?: string
92
				href?: string
93
				name?: string
94
			}
95
		} & {
96
			location?: { key?: string; id?: string; name?: string; href?: string }
97
			department?: { key?: string; id?: string; name?: string; href?: string }
98
		}
99
		audit?: {
100
			createdDateTime?: string
101
			modifiedDateTime?: string
102
			createdBy?: string
103
			modifiedBy?: string
104
		}
105
	}
106
) {
107
	const url = new URL(`https://api.intacct.com/ia/api/v1/objects/time/timesheet-line/${key}`)
108

109
	const response = await fetch(url, {
110
		method: 'PATCH',
111
		headers: {
112
			'Content-Type': 'application/json',
113
			Authorization: 'Bearer ' + auth.token
114
		},
115
		body: JSON.stringify(body)
116
	})
117
	if (!response.ok) {
118
		const text = await response.text()
119
		throw new Error(`${response.status} ${text}`)
120
	}
121
	return await response.json()
122
}
123