+* This example script console script shows how to change the owner of a filter or dashboard .
+* Note this script should be run as the ScriptRunner add on user
+* "All right, title and interest in this code snippet shall remain the exclusive intellectual property of Adaptavist Group Ltd and its affiliates. Customers with a valid ScriptRunner
+* license shall be granted a non-exclusive, non-transferable, freely revocable right to use this code snippet only within their own instance of Atlassian products. This licensing notice cannot be removed or
+* amended and must be included in any circumstances where the code snippet is shared by You or a third party."
+// Note this script should be run as the ScriptRunner add on user
+// Enter the Id of the filter to update here
+// Enter the Id of the dashboard to update here
+// Enter the accountId of the new owner here
+def newOwnerAccountId = '';
+if (newOwnerAccountId.size() == 0) return "You must specify the accountId for the new user to be able to change a filter or dashboards ownership";
+if (filterId.size() > 0) {
+ def updateFilterOwner = put("/rest/api/3/filter/${filterId}/owner")
+ .header('Content-Type', 'application/json')
+ accountId: newOwnerAccountId
+ assert updateFilterOwner.status >= 200 && updateFilterOwner.status <= 300
+ logger.info("The filter with the Id: ${filterId} was updated to be owned by the user with the accountId of ${newOwnerAccountId}.")
+if (dashboardId.size() > 0) {
+ def updateDashboardOwner = put('/rest/api/3/dashboard/bulk/edit')
+ .header('Content-Type', 'application/json')
+ action : 'changeOwner',
+ newOwner : newOwnerAccountId
+ entityIds : [dashboardId.toInteger()],
+ accountId: newOwnerAccountId,
+ id : dashboardId.toInteger(),
+ assert updateDashboardOwner.status >= 200 && updateDashboardOwner.status <= 300
+ logger.info("The dashboard with the Id: ${dashboardId} was updated to be owned by the user with the accountId of ${newOwnerAccountId}.")