In the Strategy WorkStation, subscriptions owned by departed users may still exist, potentially causing clutter and management issues. Manually identifying and deleting these subscriptions can be a cumbersome and error-prone task.
The need for this script stems from the accumulation of subscriptions in various projects that are owned by users who have left the organization, making it necessary to clean up these subscriptions to maintain an organized and efficient Strategy environment.
To streamline the deletion of subscriptions owned by departed users, follow these steps in the Strategy WorkStation:
1. Connect to Your Environment: Initialize the connection to your Strategy environment.
2. Navigate to Administration: Access the administration panel to manage scripts and workflows.
3. Access Scripts Section: Go to the scripts section where you can create or modify scripts.
4. Select Your Environment: Choose the appropriate environment where the script will be executed.
5. Open Gallery Tab: In the right section of the interface, select the Gallery tab to view available workflows and scripts.
6. Expand Administration Workflows: Find and expand the Administration Workflows section to access various administrative scripts.
7. Launch 'Delete Subscriptions of Departed Users' Script: Double-click on the 'delete subscriptions of departed users' script to open it.
8. Execute the Script: Press the run button to execute the script, which will automatically delete subscriptions of departed users and print a message indicating the success or failure of the deletion for each project.

Here is the Python script in WorkStation that facilitates this operation
"""Delete all subscription in all projects which owners are departed users.
For which project message about successful (or not) deletion will be printed.
"""
from mstrio.api.projects import get_projects
from mstrio.connection import Connection, get_connection
from mstrio.distribution_services import SubscriptionManager
from mstrio.users_and_groups import list_users
def delete_subscriptions_of_departed_users(connection: "Connection") -> None:
"""Delete all subscription in all projects which owners are departed users.
Args:
Args:
connection: Strategy connection object returned by
`connection.Connection()`
"""
# get all projects that the authenticated user has access to
response = get_projects(connection, whitelist=[('ERR014', 403)])
projects_ = response.json() if response.ok else []
# get all disabled users
all_users = list_users(connection=connection)
disabled_users = [u for u in all_users if not u.enabled]
for project_ in projects_:
project_id = project_['id']
sub_manager = SubscriptionManager(connection=connection, project_id=project_id)
for user_ in disabled_users:
subs = sub_manager.list_subscriptions(owner={'id': user_.id})
msg = f"subscriptions of user with ID: {user_.id}"
msg += f" in project {project_['name']} with ID: {project_['id']}"
# call of the function below returns True if all passed
# subscriptions were deleted
if sub_manager.delete(subscriptions=subs, force=True):
print("All " + msg + " were deleted.", flush=True)
else:
print(
"Not all " + msg + " were deleted or there was no subscriptions.", flush=True
)
# connect to environment without providing user credentials
# variable `workstationData` is stored within Workstation
conn = get_connection(workstationData, 'Strategy Tutorial')
# execute deletion of addresses from departed users
delete_subscriptions_of_departed_users(conn)
Python within Workstation https://www2.Strategy.com/producthelp/Current/Workstation/en-us/Content/intro_scripts.htm
Preview Python Scripts https://www2.Strategy.com/producthelp/Current/Workstation/en-us/Content/preview_scripts.htm
mstrio-py https://github.com/MicroStrategy/mstrio-py
https://www2.Strategy.com/producthelp/Current/Workstation/en-us/Content/intro_scripts.htm
Customization Warning:
This customization is provided as a convenience to Strategy users and is only directly applicable to the version stated. While this code may apply to other releases directly, Strategy Technical Support makes no guarantees that the code provided will apply to any future or previous builds. In the event of a code change in future builds, Strategy Technical Support makes no guarantee that an updated version of this particular customization will be provided. For enhancements to this customization or to incorporate similar functionality into other versions, contact your Account Executive to inquire about Strategy Consulting assistance.