I have created a Visualforce global publisher action with the intent to add it to the Chatter actions menu for several objects in the organization. The action should be able to post a message directly to the feed of whatever Chatter feed it is added to. This is pretty easy, provided that I have the current record Id. However, I don't see how to generically get the current record Id from within the context of the Visualforce page.

I know that this is possible if I create a separate Visualforce page for every single object that I wish to use the action for and then create an object specific publisher action for each one. But what a lot of clutter for something so simple!

Is there any way to get the current record Id from within a global Visualforce publisher action? Hacks are welcome!

  • Hi Jason, I've got the same question. Did you ever find an answer? Thanks
    – DaveS
    Aug 20, 2015 at 8:55
  • No, I didn't... :( Aug 21, 2015 at 12:49

2 Answers 2


With New Lightning Url, you can simply get it within your VFPage as


I had to do the exact same thing. I used javascript on the page to deliver the raw URL and then extracted the ID within the controller. Note that we are only including the Quick Action on Object pages, not anywhere where there is no objectId. I imagine you could enhance my code to come up with the user id or group id for pages where there is no SObject id in the URL. Also, if you are working with communities, you'll have to parse out the extra community prefix part of the URL.

    var j$ = jQuery.noConflict();
    //on Document ready
 <apex:form >
    <apex:inputHidden value="{!url}" id="theUrl"/>

Then I parsed the URL in my class with:


FeedItem fItem = new FeedItem();
fItem.parentId = getSObjectId(this.url);


public String getSObjectId(String rawUrl) {
    String urlNoDomain = awUrl.substringAfter('://').substringAfter('/');
    return urlNoDomain.substringBefore('/');

You must log in to answer this question.

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