Adding a button to Document Locations Tab in CRM 2011


After we have configured SharePoint List Component for CRM 2011, and enabled it for the entities, we will have a “documents” link on the left navigation pane of the record. The ribbon will have two buttons Add Location and Edit Location over there.

If we need to add our own button over there, we need to make changes to the “Application Ribbons” in our solution file.

The final output

And the RibbonDiffXML for that

<RibbonDiffXml>
<CustomActions>
<CustomAction Id="AMS_DocumentButton" Location="Mscrm.DocumentsTab.Locations.Controls._children" Sequence="30">
<CommandUIDefinition>
<Button
Id="B_MyFirstButton"
Command="Cmd_JavaScript"
LabelText="My First Button"
ToolTipTitle="My First Button Tool Tip Title"
ToolTipDescription="My First Button Tool Tip Description"
TemplateAlias="o1"
Image16by16="/_imgs/ribbon/saveandclose16.png"
Image32by32="/_imgs/ribbon/saveandclose32.png"/>
</CommandUIDefinition>
</CustomAction>
</CustomActions>
<Templates>
<RibbonTemplates Id="Mscrm.Templates"></RibbonTemplates>
</Templates>
<CommandDefinitions>
<CommandDefinition Id="Cmd_JavaScript">
<EnableRules/>
<DisplayRules/>
<Actions>
<JavaScriptFunction
Library="$webresource:new_test"
FunctionName="testDoc">
</JavaScriptFunction>
</Actions>
</CommandDefinition>
</CommandDefinitions>
<RuleDefinitions>
<TabDisplayRules />
<DisplayRules />
<EnableRules />
</RuleDefinitions>
<LocLabels />
</RibbonDiffXml>

Hope it helps.

This solution contains invalid markup or elements that cannot be deployed as part of a sandboxed solution in SharePoint 2010.


I was getting the above error while trying to activate one of the solutions in SharePoint 2010. As it turns out it was a farm solution and not a sandboxed one.

So adding and deploying it though central admin resolved the issue.

Hope it helps !

value cannot be null. parameter name value error in CRM 2011


I was getting the above error while trying to create a SharePointDocumentLocation programmatically. However I was able to create an incident record without any issue.

As it turned out, this is what I was missing


OrganizationServiceProxy orgService = new


OrganizationServiceProxy(organizationUri, homeRealmUri, credentials, null);


orgService.EnableProxyTypes();

Hope it helps!

Charts in CRM 2011


Only a few days back I realized that it is so easy to convert our 2-d charts to 3-d in CRM 2011.

Steps are as following:-

Open the chart we want to convert to 3-d.

Suppose this is our chart

Select the Export Chart button from the Ribbon

In the exported xml for the chart add the following line (Area3DStyle), before the closing tag of ChartArea.

</AxisX>

<Area3DStyle Enable3D=”True” />

</ChartArea>

</ChartAreas>

Using Import Chart option import it back, this is how now it is gonna look like

One more thing we  can also add filter criteria to the fetch used in Chart’s xml.

Do check out these wonderful posts

http://niiranen.eu/crm/2010/10/turn-the-flat-dynamics-crm-2011-charts-into-3d/

http://blogs.msdn.com/b/crm/archive/2011/01/04/crm-2011-charts-know-the-real-potential-part-i.aspx

http://blogs.msdn.com/b/crm/archive/2011/05/02/crm-2011-charts-know-the-real-potential-part-deux.aspx

http://gtcrm.wordpress.com/2011/03/22/quick-reference-for-common-crm-2011-chart-customisations/

Hope it helps.

Send mail to a custom entity in CRM 2011


In CRM 4, to send a mail to a custom entity we used to create a new email attribute for that entity and then had to write a custom workflow activity or plugin for sending mail or some complex logic.

http://social.microsoft.com/Forums/en/crmdevelopment/thread/634aa49d-d8fc-4a8c-b3af-6c00b72f8df9

http://blogs.inetium.com/blogs/azimmer/archive/2009/08/08/crm-4-0-using-unresolved-email-addresses.aspx

Good news is that in CRM 2011 we have a new feature to Send e-mail for custom entities.

http://www.avanadeblog.com/xrm/2010/11/crm-2011-feature-of-the-week-11222010-new-entity-creation-flexibility.html

Just need to enable that option in Entity Customization form. It will create a new email field for that entity or will use an existing email field if it is already there.

Bye.

Creating a custom Weather Web Part in SharePoint 2010


Update :- The below solution doens’t work any more

http://www.tropicdesigns.net/blog/weather-com-suddenly-cancels-their-free-xml-data-feed-for-developers/

 

Recently we had a requirement to create a web part that will show the weather information based on the address of the user, which we were pulling from Microsoft Dynamics CRM’s database.

These following two links were of immense help

http://svintinner.blogspot.com/2007/02/how-to-use-weathercom-to-replace-msnbc.html

http://weatherwebpart.codeplex.com/

This is how the web part looks

Below is the sample source code for the web part

public class MyWeatherWebPart : WebPart
{
String UserLocation = "Ahmedabad"; // user city
String UserCountry = "India"; // user country
String RequestforURL = string.Empty; // URL which use to get xml data ( rss feed response ) from weather.com
System.Web.UI.WebControls.Xml xmlResults = new System.Web.UI.WebControls.Xml(); // this object contain final data we need to publish(write on sharepoint site)

protected override void Render(HtmlTextWriter writer)
{
try
{
String reqUrl = "<a href="http://xoap.weather.com/weather/local/">http://xoap.weather.com/weather/local/</a>" + GetLocaleID() + "?cc=*&dayf=5&link=xoap&prod=xoap&par=xxxxxxxx&key=xxxxxxxxxxxxxxx";
HttpWebRequest wr = (HttpWebRequest)WebRequest.Create(reqUrl);
//load the response into a response object
WebResponse resp = wr.GetResponse();
// create a new stream that can be placed into an XmlTextReader
Stream str = resp.GetResponseStream();
XmlTextReader reader = new XmlTextReader(str);
reader.XmlResolver = null;
// create a new Xml document and locading feed data in to it
XmlDocument doc = new XmlDocument();
doc.Load(reader);

// as xml style sheet is use for publishing data so we loading it into envornment
HttpContext context = HttpContext.Current; // getting refrence of current environment
// getting reference of path where sml style sheet stays
string path = context.Request.MapPath("/_layouts/RSSWeatherXSL.xsl");

// this object need to convert xml data into xml style sheet view
XslTransform trans = new XslTransform();

trans.Load(path); // loading xsl file
xmlResults.Document = doc; // loading xml data
xmlResults.Transform = trans; // transforming xml to xsl
xmlResults.DataBind(); // binding data
xmlResults.Visible = true; // setting property
xmlResults.RenderControl(writer); // rendering/publishing data as html

}
catch (Exception ex)
{
writer.Write(ex.Message);
}

}
/// <summary>
///   GetLocaleID() THIS METHOD USED TO GET LOCATION ID WHICH we NEED TO GET WEATHER RSS FEED
/// THIS METHOD USE USER CITY AND COUNTRY INFORMATION
/// </summary>
/// <returns></returns>
public string GetLocaleID()
{
try
{
RequestforURL = "<a href="http://xoap.weather.com/search/search?where">http://xoap.weather.com/search/search?where</a>=" + UserLocation.ToString() + "," + UserCountry.ToString();
// First we request our content from our provider source .. in this case .. The Weather Channel
HttpWebRequest wr = (HttpWebRequest)WebRequest.Create(RequestforURL);
//load the response into a response object
WebResponse resp = wr.GetResponse();
// converting it into stream
Stream str = resp.GetResponseStream();
// creating xml reader
XmlTextReader XmlTextReader = new XmlTextReader(str);
XmlTextReader.XmlResolver = null;
XmlDocument doc = new XmlDocument();
// loading xml data in xml doc
doc.Load(XmlTextReader);
// searching location id
return doc.DocumentElement.ParentNode.LastChild.FirstChild.Attributes[0].Value;
}
catch(Exception ex)
{
throw ex; // any exception then default value i.e toronto, canada
}
}
}

Bye.