Add or Update Values for List Fields
One script reply has been approved by the moderators Verified

This resource accepts one or more options. To update an option, specify an ID. You may also remove an option from the list of current values by archiving the value. To create a new option, do not specify an "id" attribute.

Created by hugo697 51 days ago
Submitted by hugo697 Bun
Verified 51 days ago
1
//native
2
/**
3
 * Add or Update Values for List Fields
4
 * This resource accepts one or more options. To update an option, specify an ID. You may also remove an option from the list of current values by archiving the value. To create a new option, do not specify an "id" attribute.
5
 */
6
export async function main(
7
	auth: RT.BambooHr,
8
	listFieldId: string,
9
	body: AddOrUpdateValuesForListFields
10
) {
11
	const url = new URL(`https://${auth.companyDomain}.bamboohr.com/api/v1/meta/lists/${listFieldId}`)
12

13
	const response = await fetch(url, {
14
		method: 'PUT',
15
		headers: {
16
			'Content-Type': 'application/json',
17
			Authorization: 'Basic ' + btoa(`${auth.apiKey}:x`)
18
		},
19
		body: JSON.stringify(body)
20
	})
21
	if (!response.ok) {
22
		const text = await response.text()
23
		throw new Error(`${response.status} ${text}`)
24
	}
25
	return await response.text()
26
}
27

28
/* eslint-disable */
29
/**
30
 * This file was automatically generated by json-schema-to-typescript.
31
 * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
32
 * and run json-schema-to-typescript to regenerate this file.
33
 */
34

35
export interface AddOrUpdateValuesForListFields {
36
	options?: {
37
		id?: number
38
		value?: string
39
		archived?: string
40
		adpCode?: string
41
		[k: string]: unknown
42
	}[]
43
	[k: string]: unknown
44
}
45