Recipes by Category

App Distribution (2) Bundle logic, interface and services for distribution. App Logic (37) The Apex programming language, workflow and formulas for logic. Collaboration (5) The Salesforce Chatter collaboration platform. Database (29) Data persistence, reporting and analytics. Integration (33) Web Service APIs and toolkits for integration. Security (9) Platform, application and data security. Tools (4) tooling User Interface (36) Visualforce MVC and metadata-drive user interfaces. Web Sites (12) Public web sites and apps with optional user registration and login.
Beta Feedback
Cookbook Home » Adding a Feed to Your Site

Adding a Feed to Your Site

Post by Developer Force  (2010-07-16)

Status: Certified
Level: novice


Your site is up and running, and you'd like to add a feed that shows your users up to the last 20 accounts added to your organization.


Define a feed and add it to a Visualforce page in your site. Users can then click an icon to subscribe to the feed.

Before you start, make sure that Sites are enabled and that you have set up a site as described in the online help, including setting the public access settings and enabling feeds for your site.

To create a feed and add it to a Visualforce page in your site:

  1. Click Setup | Develop | Sites to display the list of sites created for your organization.
  2. Click the name of the site where you want to add a feed. Click the Site Label link, not the Site URL link.
  3. In the Syndication Feeds detail area, click New and enter the following values:
    • Name: LatestAccounts
    • Description: Up to the last 20 accounts added to our organization.
    • Query: SELECT Name from Account
    • Mapping ft: "test", fa:"Mysti", et:"Account", ec:Name
    • Max Cache Age Seconds: 600
  4. Click Save, then click Back to Site Detail to return to the sites detail page.
  5. Click Preview next to LatestAccounts to test the feed to ensure it delivers the information you expect. The preview page displays what the feed will display to users, and provides a link to the site where the feed will be displayed.
  6. After the feed is created and tested, add a link to the feed in your Visualforce page by adding the following markup:
    <A HREF="/xml/services/LatestAccounts">Latest Accounts</A>

    The path assumes your page is located in the base directory of the site. You may have to adjust the path if it is not.

  7. Now users who visit the page can click the link Latest Accounts and subscribe to the feed.


The feed created here is very simple. You can write much more complex SOQL queries for the feed to tailor the information for your users. For example, the following query would report up the last five accounts created later than yesterday:

SELECT Name from Account where CreatedDate < Yesterday LIMIT 5

The SOQL query defines what information is collected, but the mapping determines what information is displayed in the feed itself, using elements of the ATOM protocol. For an explanation of the elements, see “Defining Syndication Feeds” in the online help. This topic also explains some of the limitations placed on SOQL for feeds queries. These limits are in place to ensure good performance.

It's important that you set public access settings for objects properly. Because the feed issues queries as the site guest user, you must assign the correct public access settings to the profile for that guest user, or queries may return either not enough information or information about objects that you don't wish to share with the guest user.Similarly, you must set sharing rules appropriately. Instructions for setting the public access settings and sharing rules are provided in the online help.

Feeds support the use of bind variables in both the query definition and mapping. At run time, the value of the bind variable is passed in the URL. More information about bind variables is provided in the online help.


Recipe Activity - Please Log in to write a comment

 Are there any other mapping tags available for feeds? I would like to include a photo with each post. This would help make the post look better in such news readers like Pulse.

by Mitch Fortier  (2011-04-14)

 AJ - the "1" is actually just a line number.   Use the "Copy to clipboard" option in the hover (when you mouse over the example) to get the code without the line numbers.

by Jon Mountjoy  (2011-01-17)

This is very easy to follow; however, I ran into an issue after customizing the provided link and adding it to my VF page.

I believe the link should be:
<A HREF="/services/xml/LatestAccounts">Latest Accounts</A>

instead of:

1<A HREF="/xml/services/LatestAccounts">Latest Accounts</A>

After I changed the link on my VF page, it worked great.

by AJ Barr  (2010-10-19)


Vote to Verify a Recipe

Verifying a recipe is a way to give feedback to others and broaden your own understanding of the capabilities on When you verify a recipe, please make sure the code runs, and the functionality solves the articulated problem as expected.

Please make sure:
  • All the necessary pieces are mentioned
  • You have tested the recipe in practice
  • Have sent any suggestions for improvements to the author

Please Log in to verify a recipe

You have voted to verify this recipe.