function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
lanemlanem 

salesforce.com url for data objects

The Chatter REST API gives me back the ID for objects and the URL of the REST endpoint for the object, but I would like to include, in my UI, links back to the original SalesForce pages for the object. 

 

I can do this for users by linking to instanceURL + UserID, which redirects me to <<instanceURL>>/_ui/core/userprofile/UserProfilePage for that user, which is perfect. 

 

But I’ve not found a way to use the information in the feed-item object to build up a URL for the single item view of the feed-item itself.  Any ideas?

Best Answer chosen by Admin (Salesforce Developers) 
ChrisOctagonChrisOctagon

I think you have to have knowledge about what type of feed item it is (group, user, etc). You can see what sort of URLs get used for individual feed items in a chatter org by clicking on the timestamp of feed item posts.

All Answers

ChrisOctagonChrisOctagon

I think you have to have knowledge about what type of feed item it is (group, user, etc). You can see what sort of URLs get used for individual feed items in a chatter org by clicking on the timestamp of feed item posts.

This was selected as the best answer
lanemlanem

The problem with this approach is that the Id provided from the REST API is not the same one used by the web UI.  They are clearly related, but appear to have extra characters appended.  So for instance, the URL for the UserStatus FeedItem is _ui/core/userprofile/UserProfilePage?u={0}&ChatterFeedItemId={1} where {0} is the feedItem/actor/id with the last 3 characters trimmed and  and {1} is feedItem/id with the last three characters trimmed.  This feels a bit brittle.

Thomas CookThomas Cook

What you're seeing is an 18 character version of a 15 character id.  We give out 18 character ids in the APIs because they are unambiguous from a case sensitivity standpoint, where that is not the case with a 15 char id (i.e. with a 15 char id changing the case of letters in the id could mean referencing a different record).  You should be able to construct the desired URL with the 18 char id with no issues, but please let us know if that is not the case.

lanemlanem

This did work for me and here are my findings for anyone who wants to try this.  Be advised this may not age well, though I think some of it will. 

 

1. For people, accounts, solutions, and all other data types I tested:

 

{$instanceUrl}/{$userId} will redirect to the profile page of the user.  $userId can be the 15 or 18 character identifier.

 

2. For FeedItems

 

{$instanceUrl}/{$parentId}?ChatterFeedItemId={$eventId} will redirect to the page for the parent item and display the requested feed item.  You can use 15 or 18 character identifiers.

 

 

Thanks for the help!

 

ChrisOctagonChrisOctagon

Good detective work! :) 

 

In regards to TextPost/ContentPost/LinkPost, these can also be made on groups and records, so the "/userprofile/UserProfilePage?" part will not always work. The URL depends on the parent type.

 

feed items on groups look like:

 

/_ui/core/chatter/groups/GroupProfilePage?g={$groupId}&ChatterFeedItemId={$feedItemId}

lanemlanem

I just edited my original reply.  Seems like the {&instanceUrl)/{$parentId}?ChatterFeedItemId={$feeditemId} formula redirects to the GroupProfilePage correctly too.

 

Sorry for any confusion!