3

I have to disable a button if the profile photo is default (smiley) else if the photo is uploaded then the button should be enable in a visualforce page. I have a custom contrller and a visualforce page. Any help is appreciated.

closed as unclear what you're asking by Eric, Boris Bachovski, crmprogdev, Mohith Shrivastava, sfdcfox Oct 12 '15 at 14:20

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.

2

After doing some this that I got this solution :

User usr = [SELECT usr.Id, usr.SmallPhotoUrl FROM User WHERE usr.Id =UserInfo.getUserId()

public void checkRemoveBtn()
{
         ConnectApi.ChatterUsers.deletePhoto(null, currentUser.Id);
         if(usr.SmallPhotoUrl =='/profilephoto/005/T')
            showBtn=false;
         else
            showBtn=true;

}

Since in my situation, the default profile photo and uploaded photo both has been set through Static Resources. So before checking I'm deleting to get /profilephoto/005/T URL.

0

You can use the following SOQL to find the Users who has default profile picture.

List<User> u = [SELECT Id, FullPhotoUrl, SmallPhotoUrl FROM User WHERE 
        FullPhotoUrl = 'https://c.na20.content.force.com/profilephoto/005/F'];

You will get a list of users who has default profile picture. Iterate through the user list and disable the button using Apex. Make sure to get the correct link dynamically for your Org.

Eg : https://c.na20.content.force.com/profilephoto/005/F

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