Update UI modification

Updates a UI modification. UI modification can only be updated by Forge apps. Each UI modification can define up to 1000 contexts. The same context can be assigned to maximum 100 UI modifications. **[Permissions](#permissions) required:** * *None* if the UI modification is created without contexts. * *Browse projects* [project permission](https://confluence.atlassian.com/x/yodKLg) for one or more projects, if the UI modification is created with contexts.

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
 * Update UI modification
8
 * Updates a UI modification. UI modification can only be updated by Forge apps.
9

10
Each UI modification can define up to 1000 contexts. The same context can be assigned to maximum 100 UI modifications.
11

12
**[Permissions](#permissions) required:**
13

14
 *  *None* if the UI modification is created without contexts.
15
 *  *Browse projects* [project permission](https://confluence.atlassian.com/x/yodKLg) for one or more projects, if the UI modification is created with contexts.
16
 */
17
export async function main(
18
  auth: Jira,
19
  uiModificationId: string,
20
  body: {
21
    contexts?: {
22
      id?: string;
23
      isAvailable?: boolean;
24
      issueTypeId?: string;
25
      projectId?: string;
26
      viewType?: "GIC" | "IssueView";
27
    }[];
28
    data?: string;
29
    description?: string;
30
    name?: string;
31
  }
32
) {
33
  const url = new URL(
34
    `https://${auth.domain}.atlassian.net/rest/api/2/uiModifications/${uiModificationId}`
35
  );
36

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