Thursday, March 22, 2012

Some useful functions for MS CRM 2011 Reports


Here is a couple of useful functions for MS CRM 2011 reports:


Function that used to remove the duplicate records
Public Shared Function RemoveDups(ByVal items As String) As String
         Dim noDups As New System.Collections.ArrayList()
        
         Dim SpStr
         SpStr = Split(items ,",")

         For i As Integer=0 To Ubound(Spstr)
                   If Not noDups.Contains(SpStr(i).Trim()) Then
                            noDups.Add(SpStr(i).Trim())                       
                   End If
         Next

         Dim uniqueItems As String() = New String(noDups.Count-1){}
         noDups.CopyTo(uniqueItems)
        
         Return String.Join(",", uniqueItems)
End Function

SharePoint 2010 Form Based authentication for MS CRM 2011 Plugins

Some time you need to add, delete, or update custom items in a list on the SharePoint 2010 when plugins in MS CRM is fired up. This simple function can save your time :)

Passing MS CRM 2011 CRMParameter from ribbon button to Silverlight application

It’s pretty cool when you can pass CRMParameters to Silverlight application. To do that we need to get “location” :

public static string GetCRMParametr()
{
     if (HtmlPage.IsEnabled)
    {
        dynamic location = (ScriptObject)HtmlPage.Window.GetProperty("location");
        string crmParametr = location.search;
        if(!string.IsNullOrEmpty(crmParametr))
       {
           return crmParametr
        }
    }

return null;
}

You can add some kind of dummy parser to extract guid’s from passed parameters: