serving the solutions day and night

Pages

Wednesday, November 28, 2012

Display SharePoint List in CRM Dynamics 2011

SharePoint 2010

1)Create a new View and type a name CRMView , and select “standard View”, select the display columnnames and also ZipCode column name, press OK to save the new view.



Your new view will be look similar to below image, click the ZipCode column, select any of the zip value. Copy the URL (filtered) in a notepad.


http://<SP URL>/Lists/CRMView.aspx?View={f10}&SortField=ZipCode&SortDir=Desc&FilterField1=ZipCode&FilterValue1=53209

CRM Dynamics 2011

Insert an IFRAME to in the CRM Form, add the name and the URL (the above SharePoint URL), check the Option Pass record object-type code and unique identifier as parameters. (this is for CRM to pass parameter information to SharePoint) and Click OK.


Click CRM Form Properties, Add a new JavaScript Web Resources or use existing JavsScript Web Resources,  add the below script
function SharePointURL() {
var CRM_FORM_TYPE_CREATE = 1;
var CRM_FORM_TYPE_UPDATE = 2;
var SharePointURL= "";
if(IsOnline()) {
   switch (crmForm.FormType) {
       case CRM_FORM_TYPE_CREATE:
       case CRM_FORM_TYPE_UPDATE:
                IFrameSrc= "http://<SP URL>/Lists/CRMView.aspx?View={f10}&SortField=ZipCode&SortDir=Desc&FilterField1=ZipCode&FilterValue1=";
                IFrameSrc+= encodeURIComponent(Xrm.Page.getAttribute("g_zipcode").getValue());
                crmForm.all. IFRAME_PollingPlace.src = IFrameSrc;
                break;
   }
}
}


g_zipcode - CRM attribute names are CASE Sensitives.

In The Form properties, select Control - Form and Event - OnLoad and Click Add Handler Properties. In Handler Sub Form, select Library - JavaScript WebResource and Function - JavaScript Function name (SharePointURL). Save  the form and Publish.


Open the CRM form list, select the record, the form will be display the SharePoint List with matched zipcode.

No comments: