Bulk update custom field value

Updates the value of a custom field added by Connect apps on one or more issues. The values of up to 200 custom fields can be updated. **[Permissions](#permissions) required:** Only Connect apps can make this request

Script jira Verified

by hugo697 ยท 11/2/2023

The script

Submitted by hugo697 Typescript (fetch-only)
Verified 396 days ago
1
type Jira = {
2
  username: string;
3
  password: string;
4
  domain: string;
5
};
6
/**
7
 * Bulk update custom field value
8
 * Updates the value of a custom field added by Connect apps on one or more issues.
9
The values of up to 200 custom fields can be updated.
10

11
**[Permissions](#permissions) required:** Only Connect apps can make this request
12
 */
13
export async function main(
14
  auth: Jira,
15
  Atlassian_Transfer_Id: string,
16
  body: {
17
    updateValueList?: {
18
      _type:
19
        | "StringIssueField"
20
        | "NumberIssueField"
21
        | "RichTextIssueField"
22
        | "SingleSelectIssueField"
23
        | "MultiSelectIssueField"
24
        | "TextIssueField";
25
      fieldID: number;
26
      issueID: number;
27
      number?: number;
28
      optionID?: string;
29
      richText?: string;
30
      string?: string;
31
      text?: string;
32
      [k: string]: unknown;
33
    }[];
34
  }
35
) {
36
  const url = new URL(
37
    `https://${auth.domain}.atlassian.net/rest/atlassian-connect/1/migration/field`
38
  );
39

40
  const response = await fetch(url, {
41
    method: "PUT",
42
    headers: {
43
      "Atlassian-Transfer-Id": Atlassian_Transfer_Id,
44
      "Content-Type": "application/json",
45
      Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
46
    },
47
    body: JSON.stringify(body),
48
  });
49
  if (!response.ok) {
50
    const text = await response.text();
51
    throw new Error(`${response.status} ${text}`);
52
  }
53
  return await response.json();
54
}
55