Get user ID by providing the full name

Get user ID by providing the full name

Hi all,

In my Accounts module, I have a custom field which is a picklist and consists all my Users in the instance as options. I need to create a custom function which takes the value from this custom field and change the owner of all related contacts to the user in this option set custom field.

For instance in my option set field for certain account I've chosen the user "John Doe" and I want all the contacts related to this account to have Owner "John Doe".

I need it so I can create a workflow rule which triggers the function whenever the value in this option set has been changed.

My struggle is that the option set value is of type string but the owner field is actually id which looks up to the users. So after I get the string value of the lookup field, I must filter all users by their full names and return the id of the user whose name is matching. After that, I'm updating the related contacts owner with this id.