Monday, 10 June 2013

mscrm_facebook integration : Display Contact picture from Facebook in mscrm

This Entire Integration is based on 0nly one URL and that is,
As you may Know, Each and Every User in Facebook has an Unique ID, Some change them into Alphabets called
“your Facebook URL” you can do this in Facebook Setting, and some leave as Numbers.
This User’s Facebook URL can be Generally fall in Users First and Last name, as follows
So, Most of the Organizations Collect First and Last name while creating a contact.
If you use  //Large size picture // Small size picture // Normal size Picture
the above url Displays users Profile Picture separately without any other user Information.
Now. we come to CRM,
Create a new CRM webresource javascript type and paste the following code.
function pp()
var profilepicture = Xrm.Page.getControl(“WebResource_profile”);
// ”WebResource_profile” Name of the other web resource which you place in the form to display the Picture. 
if (!profilepicture)
//Get the first and lat name of the Contact
var fn =“firstname”).getValue();
var ln =“lastname”).getValue();
var fin = fn+ln; // Concatenate the First and last name without space.
var furl = ”” + fn + “/picture?type=large”;
//Then set the finalized URL as the Source for the web-resource placed in the Form.
The Above Code downloads the Large picture from contact’s Facebook account.
Now, Customize the Entity Form by adding a new webresource, with some common profile picture as default.
add the JavaScript webresource with any message you want, onload, OnSave or Onchange of the Form method.
you can also further redesign the code by inserting a new field for facebookID and pass the data directly in to URL, in this case the CRM user must know the contacts FacebookID to Display the Picture.
I do know that the resultant picture is not 100% accurate and not reliable.
But I hope this code can be further developed which might enable the CRM users to search the Contacts in facebook and Save the Desired Picture from the result.