Twitter Feed on CRM Form

When reviewing a lead, account or contact prior to a sales call, it is always helpful to have as much context about a company prior to making the call.  Putting a Twitter feed on the CRM record for a lead can put this information in a place where it is easy for a sales person to quickly see it.  By passing in the name of the company dynamically, the feed can show relevant information about the specific company.

Twitter makes it pretty easy to generate the “base” code for integrating with CRM (or any website) as a widget.  You can find their tools for generating widgets here.  Even if you use my code, below, as a starting point, you’ll likely find this link helpful as you start to fine-tune your code a bit.

On the technical side, this post uses an HTML web resources to setup the Twitter integration on the Dynamics CRM 2011 lead form.  In general, this appears to be fairly straight forward, but there are a few ‘gotchas’ to work around.  Notably, ensuring that the script in inserted into the correct portion of the HTML code and structuring how you reference fields on your parent CRM form can be a bit tricky.

Here is a step-by-step guide to setting up the Twitter feed.  This assumes some basic knowledge of creating Web Resources in CRM.

1. Create a new Web Resource in the customizations area of CRM.  Use the following settings on it:

  • Name: Twitter
  • Display Name: Twitter Mash-Up by C5 Insight
  • Description: Displays a Twitter feed for the company on the Lead entity.
  • Type: Web Page (HTML)

2. Click Text Editor.

3. Click the source tab and enter or copy/paste the code from below.  IMPORTANT NOTE: Do not paste this code into the rich text editor – be sure  you are on the source tab.

   1:  <HTML><HEAD>
   2:  <SCRIPT charset=utf-8 src=""></SCRIPT>
   4:  <META charset=utf-8></HEAD>
   5:  <BODY contentEditable=true>
   6:  <SCRIPT>
   7:  var strName = window.parent.Xrm.Page.getAttribute('companyname').getValue(); 
   9:  new TWTR.Widget({
  10:    version: 2,
  11:    type: 'search',
  12:    search: strName,
  13:    interval: 30000,
  14:    title: 'Twitter Mentions of ',
  15:    subject: strName,
  16:    width: 'auto',
  17:    height: 175,
  18:    theme: {
  19:      shell: {
  20:        background: '#8ec1da',
  21:        color: '#ffffff'
  22:      },
  23:      tweets: {
  24:        background: '#ffffff',
  25:        color: '#444444',
  26:        links: '#1985b5'
  27:      }
  28:    },
  29:    features: {
  30:      scrollbar: true,
  31:      loop: false,
  32:      live: true,
  33:      behavior: 'all'
  34:    }
  35:  }).render().start();
  36:  </SCRIPT>
  37:  </BODY></HTML>


4. Click the OK button.  Note that you will get an error when you click this button.  You can safely ignore the error and click either Yes or No to continue.

5. Save, Publish and the Save/Close the web resource.

6. Still within the customizations area, open the Lead entity form.

7. Add the web resource you created above wherever desired.  Make it 12 rows high in order for the scrolling to show up properly – later you can update the HTML web resource and/or the number of rows used on the form to your preferences.

8. Save, Publish and then Save/Close the lead form.

9. Open up any lead in CRM and, if it has a company name, you will see the results of searching Twitter for the company name directly on the form.

You can change the code you pasted in step #3, above, to fine-tune the Twitter feed settings.  For instance, you can:

  • Post the feed to other forms (such as accounts and contacts) by referencing fields on those forms instead of the Company Name field on the lead form.
  • Using additional fields from forms (for example, you can add a custom field called “Social Searches” and allow your users to put in any other terms that they would like to search on).
  • Change the design (colors, size, etc).
  • You can also fine-tune the code by passing in the field name from the form (rather than hard coding the field name into the script in the HTML web resource).  By passing in the value, you can re-use the same web resource for multiple different forms.

Remember that this is a “mash up” to Twitter.  No data is being added to CRM with this type of integration – it is “view only.”

This is just one of many ways that you can integrate Dynamics CRM 2011 with your social media strategy.  We’re seeing quite a bit of demand for social CRM from our clients these days.  I’ll be speaking on this topic in some upcoming webcasts and will plan to publish additional social CRM blogs if there is interest in the topic here.

Special thanks go out to my colleague, Jonathan Kaufman, for his assistance in getting a value from a CRM form from within an HTML web resource as a part of creating this blog post!