Change the owner of multiple filters
Give a list of Jira filters to another user in one run, for example when someone leaves the team.
Applies to: Script Master for Jira Β· Cloud
A version of this script is in the Snippets library as the use case Change the owner of multiple filters.
Before you beginβ
- Jira permission: Jira admin (the Administer Jira global permission).
- App permission: an active Script Master license.
- The filter IDs. A filter's ID is the number at the end of its URL, for example
filter=10001. - The new owner's account ID. It's the last part of the URL of their Jira profile.
Run the scriptβ
- On the Script Console tab, paste the script below into the editor.
- Replace the values of
filterIdsandnewOwnerAccountId. - Select Run.
Result: Result shows an indented list with one entry per filter, saying whether its owner changed.
// Settings
const filterIds = [10001, 10002, 10008];
const newOwnerAccountId = '<new-owner-account-id>';
// https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-filters/#api-rest-api-3-filter-id-owner-put
const output = [];
for (const filterId of filterIds) {
const response = await requestJira(`/rest/api/3/filter/${filterId}/owner`, {
method: 'PUT',
headers: { Accept: 'application/json', 'Content-Type': 'application/json' },
body: JSON.stringify({ accountId: newOwnerAccountId }),
});
if (response.status === 204) {
output.push(`Filter ${filterId}: owner changed`);
} else {
const data = await response.json();
output.push(`Filter ${filterId}: not changed. ${data.errorMessages}`);
}
}
return output;
| Placeholder | Description |
|---|---|
<new-owner-account-id> | The Atlassian account ID of the user who gets the filters. |
Relatedβ
- Use the Snippets library: the same script as a use case.
- Run a script: run a script in the Script Console.
- Bulk clone work items: another bulk task for Jira.