function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Michelle TorresanMichelle Torresan 

How do I change the record owner field of a custom object to match a custom user lookup field within that object?

I have created a customer object called Internal Team Members in which users will be assigned a role for a project. I need the owners of these records to match the user identified and assigned a role within the object. 

Any help would be greatly appreciated. Thank you in advance. 
Best Answer chosen by Michelle Torresan
Sanjay Bhati 95Sanjay Bhati 95
Hi Michelle,

Please go through my above solution, Here is the example to implement it.
1. I have a custom object Expenditure__c and a custom field AssignedUser__c(User Lookup ). and i will show all the expenditure related to current login user with single report it will show dynamically.

2. I have Created a formula field "UserValue__c" of Number return type  on Expenditure__c custom object  and enter the below formula.
IF(AssignedUser__c.Id == $User.Id , 1 , 0)

3. Created a report with Expenditure__c object and Added the filter in report with below condition and save it.
UserValue == 1

Here is the screenshot of filter in report and click on save and run and Add it in dashboard as per your requirenment.
User-added image
 
Please follow this step, This is same scnerio that you want.

All Answers

Sanjay Bhati 95Sanjay Bhati 95
Hi Michelle,

You can't change in owner field of object. you can create a validation rule that will check record ownerId must equal to your custom user field.

Please let me know after trying this way. 
Michelle TorresanMichelle Torresan
Hi Sanjay, 

I need it for reporting purposes so that I can filter by "my internal team members".  In this custom object anyone can assign user roles for the project, so I thought that if I was able to create a trigger to change the record owner, I could filter the report to view "my internal team members" allowing users to see only roles that are associated to them. Is there a different way I can filter a report without having to create a separate report for each sales user? 
Sanjay Bhati 95Sanjay Bhati 95
Hi Michelle,

Please try this solution.

1. Create a formula field with below condition on your custom object.
IF(Custom_User_Lookup_Field__c.Id == $User.Id , 1 , 0)

2. Add below filter when you are going to create report.
Field: Custom Formula Field Name
Operator: equals
Value: 1
3. Report look like below screenshot.
User-added image

Please let me know your feedback.
 
Michelle TorresanMichelle Torresan
Hi Sanjay, thank you so much for helping solve this problem.

I do not see how this will help me with my dashboard reports. I want each user to see projects that they have been assigned a role without having to create separate reports for each user. Using the Show me filter, I right now do not have the option to view my internal team members. I can only see all-this is forcing me to create another filter that says when the user field = a specific name. I'm trying to find a workaround so that I can create a report that will only show records that are relevant to me as I would like to use the running user dashboard feature.  This is why I wanted the record owner to change to the user name in the custom user field. - Hope I have explained my situation better. Thanks again. 
Sanjay Bhati 95Sanjay Bhati 95
Hi Michelle,

Please go through my above solution, Here is the example to implement it.
1. I have a custom object Expenditure__c and a custom field AssignedUser__c(User Lookup ). and i will show all the expenditure related to current login user with single report it will show dynamically.

2. I have Created a formula field "UserValue__c" of Number return type  on Expenditure__c custom object  and enter the below formula.
IF(AssignedUser__c.Id == $User.Id , 1 , 0)

3. Created a report with Expenditure__c object and Added the filter in report with below condition and save it.
UserValue == 1

Here is the screenshot of filter in report and click on save and run and Add it in dashboard as per your requirenment.
User-added image
 
Please follow this step, This is same scnerio that you want.
This was selected as the best answer
Michelle TorresanMichelle Torresan
Hi Sanjay, 

Thank you for explaining it further. For some reason, when I check syntax it gives me an error saying that the field does not exist on the custom object... yet it does (see image below) Any thoughts as to why that is? 

I do have an active WFR that automatically creates an "internal team member" when a an owner of a record on a related object is added to an opportunity. 

Thank you again for your help. 

User-added image
User-added image
 
Michelle TorresanMichelle Torresan
Nevermind,  I removed id and it worked. Thank you so much for your time. I really appreciate it.