The chatter profile picture url is saved in the User FullPhotoUrl field.

If we try to modify the picture/upload a new picture in the chatter profile image, the trigger in the user object is not triggered.

Is there any way to invoke a trigger when the chatter profile image is modified.

trigger UpdateChatterPicture on User (after insert, after update) { List<UserPhoto__c> lstInsertPhoto = new List<UserPhoto__c>(); List<UserPhoto__c> lstUpdatePhoto = new List<UserPhoto__c>(); List<UserPhoto__c> lstUserPhoto = new list<UserPhoto__c>(); Map<Id,UserPhoto__c> MapUserPhotoId = new map<id,UserPhoto__c>(); List<UserPhoto__c> lstAllUsrPhoto = new List<UserPhoto__c>(); lstUserPhoto = [select Id, Name, User__c, (select id from attachments) from UserPhoto__c where User__c in: trigger.newmap.keyset()]; System.debug('Trigger:lstUserPhoto='+lstUserPhoto); for(UserPhoto__c userphoto : lstUserPhoto) { MapUserPhotoId.put(userphoto.User__c , userphoto); } System.debug('Trigger:MapUserPhotoId='+MapUserPhotoId); for(User user : trigger.new) { if(Trigger.IsInsert && user.isIVExchangeUser__c == true) { UserPhoto__c photo = new UserPhoto__c(); photo.Name = user.Name; photo.User__c = user.Id; photo.PhotoURL__c = user.FullPhotoURL; lstInsertPhoto.add(photo); System.debug('Trigger:photo='+photo); } else if(Trigger.IsUpdate && user.isIVExchangeUser__c == true) { user oldUsr = Trigger.oldMap.get(user.Id); if (oldUsr.FullPhotoURL != User.FullPhotoURL) { UserPhoto__c usrphoto = MapUserPhotoId.get(user.id); usrphoto.PhotoURL__c = User.FullPhotoURL; lstUpdatePhoto.add(usrphoto); System.debug('Trigger:Updatephoto='+usrphoto); } } } try { insert lstInsertPhoto; update lstUpdatePhoto; } Catch(Exception ex) { } lstAllUsrPhoto.addall(lstInsertPhoto); lstAllUsrPhoto.addall(lstUpdatePhoto); System.debug('Trigger:lstAllUsrPhoto'+lstAllUsrPhoto); //calling class to insert attachment clsUpdateUserPhotoAttachment.UpdateUserPhotoAttachment(lstAllUsrPhoto); }

Thanks in advance.

  • Can you post up some sample code? Commented Oct 5, 2012 at 14:33
  • You need to first find whether on change of the picture is your field on the user getting updated or not ?If yes then there can be some trigger issues and may require debug.Can you put more detail into question Commented Oct 5, 2012 at 15:12
  • Yes it is getting updated. I checked it via workbench. I debug the trigger also but the trigger is not invoked during the photo upload
    – Priyanka
    Commented Oct 5, 2012 at 15:17
  • DavinC, added my code in my question
    – Priyanka
    Commented Oct 5, 2012 at 15:31
  • 1
    there's no trigger fired because there's no value stored, the photoUrl fields are calculated when the row is read (like a formula field), not a stored value.
    – superfell
    Commented Oct 5, 2012 at 15:36

2 Answers 2


Just reading the other question you posted where your objective is to actually display the chatter photo on a vf page on the portal.

I read you went down this custom object route coz the Api route wasn't playing ball.

You can use the solution in the blog you mentioned (http://blogs.developerforce.com/developer-relations/2011/03/accessing-chatter-user-pics.html) even with a session id, you don't need an oauth token.

To get a sessionId all you need is a login call which you can obtain using the Ajax toolkit http://www.salesforce.com/us/developer/docs/ajax/index.htm

Here's a bit of sample code that fetches the photo at page load and redirects to the url


<script src="../../soap/ajax/26.0/connection.js" type="text/javascript" />
<script type="text/javascript" >
window.onload = connectRemotely;

function connectRemotely(){
     var result = sforce.connection.login("[email protected]", "PASSWORD + SECURITY TOKEN");
     window.location.href = "https://c.XXX.content.force.com/profilephoto/USERID/F?oauth_token=" + result.sessionId;

  • Just curious - did this answer your question ? Commented Oct 8, 2012 at 13:32
  • In the given solution, how can I provide external user password and security token?
    – Priyanka
    Commented Oct 9, 2012 at 7:31
  • Could you not just have an integration user which you use. Oauth is preferable I guess, but if that's too complex, I reckoned this was a workaround. Commented Oct 9, 2012 at 7:35
  • FYI, my understanding is that the AJAX API, which is used by this solution, will not be supported in Salesforce Communities, which are replacing Customer Portals as of Summer '13.
    – Benj
    Commented May 1, 2013 at 18:35

Finally, I wrote a scheduler class and updated the picture at regular intervals.

Anybody if you find any other solution, please let me know.

  • How did you able to convert FullPhotoURL to a blob in a scheduler without a session id to pass for oAuthToken? I am trying a similar thing but running into problem when I execute in batch mode. Appreciate your help on this
    – user2623
    Commented Mar 28, 2013 at 21:40
  • ConnectAPi.getPhoto provides standardEmailPhotoURL, which is public url and can be used to get blob without oAuth Token. Commented Jun 25, 2015 at 5:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .