Working with Del.icio.us data

In this recipe, we will have a quick look at leveraging a tagging site such as Del.icio.us to determine the popularity of an account. If you intend to use this in a production environment I would suggest relying on a combination of multiple sources. Take this result with a grain of salt, unless your business revolves around this. This example is only to show you how you can get data from Del.icio.us and use it within Dynamics CRM. You can expand on this example and retrieve the actual tags of a specific account or any other information stored on Del.icio.us.

Note

The updated URL now for Del.icio.us is www.delicious.com, but for most of us who have used it since the inception, del.icio.us still rings the bell.

Getting ready

For this recipe you will need the jQuery library. Head over to http://jquery.com/ and grab the latest version from there.

Make sure you have the system customizer or system administrator permission in the environment you will be developing in.

You can re-use a previously created solution package, or create a new one.

How to do it...

As previously described in other recipes, you will need the jQuery library. Assuming you have downloaded it already, perform the following steps:

  1. Open your solution package, or create a new one if one doesn't already exist.
  2. Add a new web resource of type JScript. Name it jQuery and load the jQuery library.
  3. Save and Publish your resource.
  4. Add the Account entity to your solution package if not already added.
  5. Open the Account main form for editing.
  6. Add a new text field to store the popularity index value returned by our function. Make this a read-only field and name it Del.icio.us index (new_popularity).
    How to do it...
  7. Save and add this field to the form.
  8. Add to the form properties on the OnLoad, a reference to your getDelicious function.
  9. Also, on the OnChange event of the Web Site (websiteurl) field, add a reference to the same getDelicious function.
  10. Save and Publish your form.
  11. Add a new web resource of type JScript. Name it new_delicious.
  12. Add the following function to your web resource:
    function getDelicious()
    {
      var _deliciousURL = Xrm.Page.getAttribute("websiteurl").getValue();
      if(_deliciousURL != null && _deliciousURL != "")
      {
        $.ajax({ 
          type: "GET",
          dataType: "json",
          url: "http://feeds.delicious.com/v2/json/urlinfo/data?url="+_deliciousURL+"&callback=?",
          success: function(data){			
            var count = 0;
            if (data.length > 0) {
              count = data[0].total_posts;
            }
    Xrm.Page.getAttribute("new_popularity").setValue(count.tString());
        }
      });
      }
    }
  13. Save and Publish your web resource.
  14. In order to test, open an account and make sure that it has a website populated. If not, add a website.
  15. Your De.icio.us index field will populate with the bookmark count of that URL from Del.icio.us.
    How to do it...

How it works...

We are calling our function in two places in this example, to make sure we bring an updated bookmark count every time the URL changes or when a user opens an existing account.

Our function queries the Del.icio.us API and retrieves the total number of bookmarks for the specified URL. We are using jQuery Ajax for the call.

There's more...

Using a similar approach, you can query for additional information from Del.icio.us. You might want to query specific tags or even all the posts of an account or contact if they have an account on that system.

See also

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.149.229.19