Currently we are using a custom self registration page on community to allow users to register for the community. As a part of this registration process, we want to assign a default profile picture to the user which is different from the one provided by Salesforce chatter.

When I try to update the profile picture using setPhoto method of ConnectApi in user trigger, I get an error.

Guest user does not have access to this method. 

I have tried using @futuremethods and also tried using without sharing on apex trigger. Chatter methods executing based on the current users context regardless of the execution context is causing the issue here.

If anyone faced a similar issue and have figured out the solution to this, please post an answer.

Basically, my goal here is to be able to set the profile picture of the user to a default pic when they sign up using the self registration form. Thanks.

  • Post your full code to better assist – Mohith Shrivastava Aug 30 '16 at 6:22
  • Controller for component : CustomCommunitiesSelfRegController – Karthikeya Pammi Aug 30 '16 at 6:40
  • @MohithShrivastava I currently dont have the userTrigger code with me,but when the user is inserted, the following is method is called ConnectApi.UserProfiles.setPhoto(communityId, userId, fileId, versionNumber) – Karthikeya Pammi Aug 30 '16 at 6:45
  • @MohithShrivastava Found it. Here is the UserHandler class for the User Trigger. – Karthikeya Pammi Aug 30 '16 at 6:48
  • @KarthikeyaPammi : Guest don't have Profile Pics, that's why you are not able to call setPhoto method. Do you want to give default photo to new user being created ?\ – Ankuli Aug 30 '16 at 13:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.