Using Python , How to add user to existing groups?

Hello Community,

Refering to [1.0.0 / User Management & Permissions] on help.celonis.de

I have " 5 new users" (created via python) , now i want to add it to existing group using python.

user = User.create_new(“Dummy1”, “fname”, “lname”, “email@abc.com”, “password123”)
user = User.create_new(“Dummy2”, “fname”, “lname”, “email@abc.com”, “password123”)
user = User.create_new(“Dummy3”, “fname”, “lname”, “email@abc.com”, “password123”)
user = User.create_new(“Dummy4”, “fname”, “lname”, “email@abc.com”, “password123”)
user = User.create_new(“Dummy4”, “fname”, “lname”, “email@abc.com”, “password123”)

I already have existing 2 user groups , i.e Viewers , Analysts

Now I want to Assign user Dummy 1 and Dummy 2 to Group “Analysts” and I want to Assign user Dummy 3, Dummy 4 and Dummy 5 to Group “Viewers” :- like below

Groups User
Analyst Dummy 1
Analyst Dummy 2
Viewers Dummy 3
Viewers Dummy 4
Viewers Dummy 5

Now If I try to assign the user to the Group using “group.add_user(user)”

However , how to I assign my existing Group Name to the group variable ?

Hi Community,

Issue is resolved now using python Method is given below

user1 = User.create_new(“Dummy1VivekOza”, “Vivek”, “Oza”, “vivek.oza@celonis.com”, “Celonis@123”)
user2 = User.create_new(“Dummy2VivekOza”, “Vivek”, “Oza”, “vivek.oza@celonis.com”, “Celonis@123”)
user3 = User.create_new(“Dummy3VivekOza”, “Vivek”, “Oza”, “vivek.oza@celonis.com”, “Celonis@123”)
user4 = User.create_new(“Dummy4VivekOza”, “Vivek”, “Oza”, “vivek.oza@celonis.com”, “Celonis@123”)
user5 = User.create_new(“Dummy5VivekOza”, “Vivek”, “Oza”, “vivek.oza@celonis.com”, “Celonis@123”)

my_list_analysts_groupname = [“Analysts”]
my_list_viewers_groupname = [“Viewer”]

group = Group.load_all()
user = User.load_all()

for ga1 in group:
for ga in my_list_analysts_groupname:
if ga1.name == ga:
ga1.add_user(user1,user2)

group = Group.load_all()
user = User.load_all()

for gv1 in group:
for gv in my_list_viewers_groupname:
if gv1.name == gv:
gv1.add_user(user3,user4,user5)

Similarly , can also delete users

my_list_del_username = [“Dummy3VivekOza”,“Dummy4VivekOza”,“Dummy5VivekOza”]
users = User.load_all()
for u in users:
for d in my_list_del_username:
if u.username == d:
User.delete(u)

Thanks and Regards
Vivek Oza

3 Likes