The "connectapi" provide classess and static methods to access chatter data which is available through Chatter REST API. This is also referred as "Chatter in Apex". It exposes the data in localized and structured way.
Chatter in apex provides "UserProfiles" class which provides different methods to access information about users profile data.
Before version 35, "Chatterusers" class was there which was used to access information about users, such as activity, followers, subscriptions, files, and groups. Now this class is not available.
We will use UserProfiles class to update chatter user photo. You can either upload the image in documents or at any place. We need blob representation of that image and can be used to update profile photo using blob variable.
Below is sample code:
Document doc=[SELECT id, body FROM Document WHERE Name='ProfilePhoto' LIMIT 1];
//set the photo on the user's profile
ConnectApi.UserProfiles.setPhoto(null, UserInfo.getUserId(), new ConnectApi.BinaryInput(doc.body,'image/jpg','user.jpg'));
I Have uploaded image in documents and then updating the profile photo on chatter.
If you store profile photo in files, then you can use below syntax to update chatter profile photo:
ConnectApi.UserProfiles.setPhoto(null, UserInfo.getUserId(), '0690I00000D42WT',null);
This method takes 4 parameters
Chatter in apex provides "UserProfiles" class which provides different methods to access information about users profile data.
Before version 35, "Chatterusers" class was there which was used to access information about users, such as activity, followers, subscriptions, files, and groups. Now this class is not available.
We will use UserProfiles class to update chatter user photo. You can either upload the image in documents or at any place. We need blob representation of that image and can be used to update profile photo using blob variable.
Below is sample code:
Document doc=[SELECT id, body FROM Document WHERE Name='ProfilePhoto' LIMIT 1];
//set the photo on the user's profile
ConnectApi.UserProfiles.setPhoto(null, UserInfo.getUserId(), new ConnectApi.BinaryInput(doc.body,'image/jpg','user.jpg'));
I Have uploaded image in documents and then updating the profile photo on chatter.
setPhoto method require below attributes:
- communityId (string)- specify the community Id or specify null for internal users
- userid(string)- 15 digit or 18 digit user recordId
- Image details (ConnectApi.BinaryInput) - you need to specify the blob(content of file), MIME type of content and file name(string).
If you store profile photo in files, then you can use below syntax to update chatter profile photo:
ConnectApi.UserProfiles.setPhoto(null, UserInfo.getUserId(), '0690I00000D42WT',null);
This method takes 4 parameters
- communityId (string)- specify the community Id or specify null for internal users.
- userid(string)- 15 digit or 18 digit user's recordId.
- fileId(string) - 15 or 18 digit file Id.
- version number(integer) - Version number of the existing file. Specify either an existing version number, or null to get the latest version.
Amazing post
ReplyDeleteThis particular is usually apparently essential and moreover outstanding truth along with for sure fair-minded and moreover admittedly useful My business is looking to find in advance designed for this specific useful stuffs… chiropodists drills
ReplyDeleteThis is my first visit to your web journal! We are a group of volunteers and new activities in the same specialty. Website gave us helpful data to work. childcare photographer
ReplyDeleteThank you for this fascinating post, I am happy I observed this website on Google. Not just content, in fact, the whole site is fantastic. dotcom secrets
ReplyDeleteInterested in writing articles and don’t know where to find the right one? Then the service will help you find excellent https://papernow.org/buy-assignment articles in this, write any article for the order, or write an essay for you
ReplyDeleteA round of applause for your mind blowing article. Much thanks to you. Fantastic.
ReplyDeletePlaces of work demand profiles complementing capabilities for a given occupation. Well known sites are upgraded by profile creators having a thorough foundation managing the current subjects. Márcio Miranda Maia
ReplyDeletehttps://www.floraindia.com/cake-delivery/delhi.html Wedding cakes date back as far as the Roman Empire, long before the traditional iced white cake we know today was even conceived. But their evolution was not an overnight development, the wedding cake actually evolved from a number of traditions that were practiced in ancient Rome.
ReplyDeleteWith the beginning of computerized photography, it has become workable for everybody to learn and perform effective photo editing.
ReplyDeletecar photo editing service
Thanks for sharing this insightful guide on updating Chatter User Profile Photos using Connect API! 👨💻📸 The use of the 'User Profiles' class and handling image uploads via documents makes it clear and actionable. Great code snippet for those navigating through this process. Professional Car Photo Editing Service
ReplyDelete"BizTrader: Your wardrobe of business attire. 'Business For Sale' listings are the outfits in your entrepreneurial closet. Start dressing for success!"
ReplyDeleteQUICK EASY EMERGENCY URGENT LOANS LOAN OFFER EVERYONE APPLY NOW +918929509036 financialserviceoffer876@gmail.com Dr. James Eric
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteOutsourcing a car photo editing service is an efficient and cost-effective way to improve the quality of your car images. It can help you achieve a consistent and aesthetically pleasing look for your car images, speed up the editing process, and reduce the time you spend editing.
ReplyDelete