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
Bhavik MistryBhavik Mistry 

Accessing a custom field created by a managed package through Apex Class

This is my current setup:
- I have a managed package that creates a custom field on the User object (User.MyApp__MyApp_API_token__c). It stores the users API token to connect to an external system via REST.
- The Apex class I have written requests the API key from the current user, and if it does not exist, it contacts the external system to retrieve one and save it to the custom field listed above. 

This workflow works fine in my developer edition account, but when I install the app in my colleague's developer edition account, the custom field is not appearing in the UI (user profile page or user detail page) and the Apex code is not saving the retrieved API token to the User object. What is peculiar is that the custom field is created when the managed app is installed, and I can see it when I access the User object through Setup --> Object Manager.

Any help or suggestions would be much appreciated.

--Bhavik
Rahul KhilwaniRahul Khilwani
Have you checked the profile, if the field is accessable to the desired profile.
Bhavik MistryBhavik Mistry
How would I check that? It is not avaiable in the Profile view. Is there somewhere that setting is controlled?
Rahul KhilwaniRahul Khilwani
To check the field visablility you need to login with System Admin login. Go to Users fields > click on the field a new window will open, click button "set field level security" and select the field as visible or read only (As required) for the desired profile.
Bhavik MistryBhavik Mistry
The account I am testing with is also a developer account. Is this found through Setup->Object Manager->User?
Rahul KhilwaniRahul Khilwani
Under the Object manager you need to search the object Users and search for the field. Click the field label and then click set field level security.
And check if the field is visable to Admin or not.

Have a look to it and let me know if this works.

Regards
Rahul.