0

My requirement is as follows (please note both the things I have to do programmatically) 1. To upload a profile photo for an user 2. And then make the image available for user/other users to view on that user's profile page.

For the first requirement, my approach was to create an Attachment with parent-Id as the User's ID for whom a picture attachment have been created.

But unfortunately, User record can't have an attachment. However, User have contact object reference and contact can have an attachment. (this I did to achieve feature one). Limitation for this approach is, I have to create a Contact and Account object.

Now to show the image on user's profile, I created a custom formula field (in User object) which uses the uploaded attachment's id [can be reached through contact reference present in User object] to show the image on User's profile.

This question is to just validate the approach or if there is any better approach for Photo upload for user.

closed as unclear what you're asking by Mohith Shrivastava, crmprogdev, Sebastian Kessel, Himanshu, Boris Bachovski May 29 '16 at 6:40

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    Are you trying to update their profile photo? Are these actually community users? – Adrian Larson May 28 '16 at 14:24
  • If User, look at the Object Reference for User. there are several fields that need updated including FullPhotoUrl and SmallPhotoUrl. It doesn't become an attachment. – crmprogdev May 28 '16 at 15:05
  • @AdrianLarson Users would be standard users and these users would be created first and then photo for them would be uploaded using Apex rest api. – sakura May 28 '16 at 15:42
  • @crmprogdev I checked these fields (FullPhotoUrl and SmallPhotoUrl) but am not sure how to use these fields programmatically (using Apex to upload the photo and use these fields). – sakura May 28 '16 at 15:53
  • Wherever you upload/save these files to, the URL needs to be saved in the FullPhotoUrl field. There's a size limit for display in profiles on an image. If you're resizing images, after resizing &saving to another location, set the SmallPhotoUrl. If the file satisfies the size requirement, set both fields to where you're saving it. – crmprogdev May 28 '16 at 15:58
1

Your question seems to have an answer here.

You could use the new Connect API.

Specifically the ChatterUsers Class with the setPhoto method.

Not the answer you're looking for? Browse other questions tagged or ask your own question.