Set user role on document insert

Hi there.

I’m trying to assign a user a role when they create a new doc under a doctype. I have so far tried to use document hooks in the hooks.py file with “after_insert” and the also the Python file found in the doctype itself but even though it throws no error, it doesn’t complete the adding of the role. Any advice. Here is my function:

image

image