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

Field being populated is showing record ID, not the data in the field

On a previous thread:

I had an issue with mapping custom fields from the owner of an account to a custom object. I have that working but I now have one small issue. I mapped the standard field "Role" and I'm populating the "User Role" field in my custom object with the following code:


        if (xxx.Owner_Role__c == null)
            xxx.Owner_Role__c =;

 The problem is it is showing the record ID, not the text in the field from the user record. The field in the user record has "200" as the role. In my test I'm getting 00E30000000bwlUXXX  in the custom object field. How do I fix this so it will show "200" in the custom object field?



Hi Volly,


              Here in your above code you are retrieving the Id not the role name , to do so u will have to do one more query on the User object. This is how u should do :


1) Retrieve the OwnerId.

2) Query the rolename in user object for the respective ownerid.

(Query: Select UserRole.Name,UserRoleId From User where id='retrieved userid')

3) Assign the field to the desired destination field