0

Update a user view

by
Published Oct 17, 2025

Updates an existing user view 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 user view
7
 * Updates an existing user view 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
		name?: string
16
		href?: string
17
		status?: 'active' | 'inactive'
18
		description?: string
19
		object?: string
20
		category?: string
21
		viewVersion?: string
22
		isPublic?: false | true
23
		context?: string
24
		query?: {
25
			object?: string
26
			fields?: string[]
27
			filters?:
28
				| { $eq?: {} }
29
				| { $ne?: {} }
30
				| { $lt?: {} }
31
				| { $lte?: {} }
32
				| { $gt?: {} }
33
				| { $gte?: {} }
34
				| { $in?: {} }
35
				| { $notIn?: {} }
36
				| { $between?: {} }
37
				| { $notBetween?: {} }
38
				| { $contains?: {} }
39
				| { $notContains?: {} }
40
				| { $startsWith?: {} }
41
				| { $notStartsWith?: {} }
42
				| { $endsWith?: {} }
43
				| { $notEndsWith?: {} }[]
44
			filterExpression?: string
45
			filterParameters?: {
46
				asOfDate?: string
47
				includeHierarchyFields?: false | true
48
				caseSensitiveComparison?: false | true
49
				includePrivate?: false | true
50
			}
51
			orderBy?: {}[]
52
			start?: number
53
			size?: number
54
		} & {}
55
		metadata?: {
56
			frozenColumnsCount?: number
57
			columns?: { id?: string; format?: string; size?: number }[]
58
		}
59
		owner?: { key?: string; id?: string; href?: string }
60
		audit?: {
61
			createdDateTime?: string
62
			modifiedDateTime?: string
63
			createdBy?: string
64
			modifiedBy?: string
65
		}
66
	} & { id?: {} }
67
) {
68
	const url = new URL(`https://api.intacct.com/ia/api/v1/objects/core/user-view/${key}`)
69

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