<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>MSCRM Blogger &#187; Addons</title>
	<atom:link href="http://mscrmblogger.com/category/addons/feed/" rel="self" type="application/rss+xml" />
	<link>http://mscrmblogger.com</link>
	<description>Achieving it all with Microsoft Dynamics CRM™</description>
	<lastBuildDate>Fri, 09 Jul 2010 14:57:43 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>CRM Workflow Manipulation Library</title>
		<link>http://mscrmblogger.com/2010/07/08/crm-workflow-manipulation-library/</link>
		<comments>http://mscrmblogger.com/2010/07/08/crm-workflow-manipulation-library/#comments</comments>
		<pubDate>Thu, 08 Jul 2010 22:55:43 +0000</pubDate>
		<dc:creator>Carlton Colter</dc:creator>
				<category><![CDATA[Addons]]></category>
		<category><![CDATA[Scoperta]]></category>
		<category><![CDATA[crm]]></category>
		<category><![CDATA[crm 4]]></category>
		<category><![CDATA[crm4]]></category>
		<category><![CDATA[equations]]></category>
		<category><![CDATA[math]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[microsoft dynamics CRM 4]]></category>
		<category><![CDATA[regex]]></category>
		<category><![CDATA[strings]]></category>
		<category><![CDATA[workflow]]></category>

		<guid isPermaLink="false">http://mscrmblogger.com/?p=231</guid>
		<description><![CDATA[<p>The <a href="http://manipulationlibrary.codeplex.com/">CRM Workflow Manipulation Library</a> is now on CodePlex.  The CRM Workflow Manipulation Library for CRM is a set of custom workflows for OnPremise Microsoft Dynamics® CRM to solve equations, manipulates strings, perform regex (regular expression) formatting and matching, as well as SoundEx and Metaphone-Like codification.</p>]]></description>
			<content:encoded><![CDATA[<p>Microsoft Dynamics CRM 4.0’s workflow designer is built right into the web-application and provides a way to conditionally perform actions in CRM.  With CRM 4.0 on-premise, custom workflow assemblies can be uploaded to the server and accessed through the web-interface.  The <a href="http://manipulationlibrary.codeplex.com/">CRM Workflow Manipulation Library</a> provides additional workflow actions to perform calculations and manipulate strings.</p>
<p></p>
<p>Two of its most notable capabilities are its ability to perform mathematical equations and phonetic codification solving for duplicate matching.</p>
<p></p>
<p>Sometimes you may want to calculate a percentage based on some of the fields on an opportunity, or you may want to perform a calculation to make a decision on who should work on a particular task.  The solve equation workflow allows you to pass parameters and specify a formula for it to solve.</p>
<p></p>
<p><b>For example:</b></p>
<table>
<tr style="font-weight:bold">
<td>Workflow Field</td>
<td>Value</td>
</tr>
<tr>
<td>Formula:</td>
<td>min(@a,@b)*@c</td>
</tr>
<tr>
<td>@a:</td>
<td>100</td>
</tr>
<tr>
<td>@b:</td>
<td>125</td>
</tr>
<tr>
<td>@c:</td>
<td>4</td>
</tr>
<tr>
<td colspan="2">&nbsp;</td>
</tr>
<tr>
<td>Result</td>
<td>400</td>
</tr>
</table>
<p>
</p>
<p></p>
<p>The benefit is that the solver can help you calculate values to include in an email or store data back to CRM.  It does more than just basic math and can handle other constants and functions.  One of the constants it can handle is rand, which generates a number from 0 to 1 similar to excel, and it handles randbetween to generate a number between two values.</p>
<p></p>
<p>The Manipulation Library contains two phonetic codification systems, SoundEx and a Metaphone-like system.  Both of these can be used to convert text to a phonetic codified string that can then be compared for duplicate detection.  There are <a href="http://manipulationlibrary.codeplex.com/wikipage?title=Duplicate%20Checking%20with%20Metaphone&amp;referringTitle=Codify%20%28Metaphone%29">complete instructions on how to configure workflow to perform SoundEx or Metaphone duplicate detection</a> in the documentation.</p>
<p></p>
<p>The CRM Workflow Manipulation Library provides Calculation Utilities, RegEx Utilities, and String Utilities.  It is a feature-rich workflow extension that provides the ability to do much more with the data already in your CRM system, and is definitely worth checking out on <a href="http://manipulationlibrary.codeplex.com/">CodePlex</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://mscrmblogger.com/2010/07/08/crm-workflow-manipulation-library/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Workflow: Geocode (and correct) Addresses with Bing Maps</title>
		<link>http://mscrmblogger.com/2010/05/20/geocode_with_bing/</link>
		<comments>http://mscrmblogger.com/2010/05/20/geocode_with_bing/#comments</comments>
		<pubDate>Thu, 20 May 2010 17:59:03 +0000</pubDate>
		<dc:creator>Carlton Colter</dc:creator>
				<category><![CDATA[Integration]]></category>
		<category><![CDATA[Plugins]]></category>
		<category><![CDATA[Scoperta]]></category>
		<category><![CDATA[address]]></category>
		<category><![CDATA[bing]]></category>
		<category><![CDATA[bing maps]]></category>
		<category><![CDATA[crm]]></category>
		<category><![CDATA[crm 4]]></category>
		<category><![CDATA[crm4]]></category>
		<category><![CDATA[csharp]]></category>
		<category><![CDATA[custom workflow]]></category>
		<category><![CDATA[geocode]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[microsoft dynamics CRM 4]]></category>
		<category><![CDATA[workflow]]></category>

		<guid isPermaLink="false">http://mscrmblogger.com/?p=221</guid>
		<description><![CDATA[Bing Maps are great.  You can geocode and correct your addresses.  While this isn't anything complicated, it is a good example of a custom workflow that uses an external webservice.]]></description>
			<content:encoded><![CDATA[<p>Bing Maps are great.  You can geocode and correct your addresses.  Depending on your level of queries and types of usage you may need to purchase credits to query Bing Maps, but I thought it was pretty straight forward. If you need to get a Bing Maps account, go <a href="http://www.microsoft.com/maps/developers/">here</a>.</p>
<p>The thing that makes this great is it is workflow.  It is not tied down to an entity.  You can use it on your custom entities, you can geocode your addresses, and correct them.  You can do address verification and geocoding.  You can control what you do using workflow.
</p>
<p>Ok, while this isn&#8217;t anything complicated, I thought it was a good example of a custom workflow that used an external webservice.  <i>Please don&#8217;t forget to create a signed key for your project.</i></p>
<p><b>Workflow Class:</b></p>
<pre name="code" class="csharp">
using System;
using System.ServiceModel;
using System.Text;
using System.Workflow.Activities;
using System.Workflow.ComponentModel;
using BingWorkflow.BingMapsGeo;
using Microsoft.Crm.Sdk;
using Microsoft.Crm.Workflow;
using Microsoft.Win32;

namespace BingWorkflow
{
    [CrmWorkflowActivity("Bing Maps", "Geocode")]
    public class VerifyAddressUsingBingMapsActivity :
        SequenceActivity
    {
        // Activity code goes here. 

        public static DependencyProperty AddressCityProperty = DependencyProperty.Register(
            "AddressCity", typeof (string), typeof (VerifyAddressUsingBingMapsActivity));

        public static DependencyProperty AddressCountryProperty = DependencyProperty.Register(
            "AddressCountry", typeof (string), typeof (VerifyAddressUsingBingMapsActivity));

        public static DependencyProperty AddressLine1Property = DependencyProperty.Register(
            "AddressLine1", typeof (string), typeof (VerifyAddressUsingBingMapsActivity));

        public static DependencyProperty AddressPostalCodeProperty = DependencyProperty.Register(
            "AddressPostalCode", typeof (string), typeof (VerifyAddressUsingBingMapsActivity));

        public static DependencyProperty AddressStateProperty = DependencyProperty.Register(
            "AddressState", typeof (string), typeof (VerifyAddressUsingBingMapsActivity));

        public static DependencyProperty BingKeyProperty = DependencyProperty.Register(
            "BingKey", typeof (string), typeof (VerifyAddressUsingBingMapsActivity));

        public static DependencyProperty OutputCityProperty = DependencyProperty.Register(
            "OutputCity", typeof (string), typeof (VerifyAddressUsingBingMapsActivity));

        public static DependencyProperty OutputCountryProperty = DependencyProperty.Register(
            "OutputCountry", typeof (string), typeof (VerifyAddressUsingBingMapsActivity));

        public static DependencyProperty OutputLatitudeProperty = DependencyProperty.Register(
            "OutputLatitude", typeof (CrmFloat), typeof (VerifyAddressUsingBingMapsActivity));

        public static DependencyProperty OutputLine1Property = DependencyProperty.Register(
            "OutputLine1", typeof (string), typeof (VerifyAddressUsingBingMapsActivity));

        public static DependencyProperty OutputLongitudeProperty = DependencyProperty.Register(
            "OutputLongitude", typeof (CrmFloat), typeof (VerifyAddressUsingBingMapsActivity));

        public static DependencyProperty OutputMultipleFoundProperty = DependencyProperty.Register(
            "OutputMultipleFound", typeof (CrmBoolean), typeof (VerifyAddressUsingBingMapsActivity));

        public static DependencyProperty OutputPostalCodeProperty = DependencyProperty.Register(
            "OutputPostalCode", typeof (string), typeof (VerifyAddressUsingBingMapsActivity));

        public static DependencyProperty OutputStateProperty = DependencyProperty.Register(
            "OutputState", typeof (string), typeof (VerifyAddressUsingBingMapsActivity));

        [CrmInput("Address City")]
        public string AddressCity
        {
            get { return (string)GetValue(AddressCityProperty); }
            set { SetValue(AddressCityProperty, value); }
        }

        [CrmInput("Address Country")]
        public string AddressCountry
        {
            get { return (string)GetValue(AddressCountryProperty); }
            set { SetValue(AddressCountryProperty, value); }
        }

        [CrmInput("Address Line 1")]
        public string AddressLine1
        {
            get { return (string)GetValue(AddressLine1Property); }
            set { SetValue(AddressLine1Property, value); }
        }

        [CrmInput("Address Postal Code")]
        public string AddressPostalCode
        {
            get { return (string)GetValue(AddressPostalCodeProperty); }
            set { SetValue(AddressPostalCodeProperty, value); }
        }

        [CrmInput("Address State Or Province")]
        public string AddressState
        {
            get { return (string)GetValue(AddressStateProperty); }
            set { SetValue(AddressStateProperty, value); }
        }

        [CrmInput("Bing API Key")]
        public string BingKey
        {
            get { return (string)GetValue(BingKeyProperty); }
            set { SetValue(BingKeyProperty, value); }
        }

        [CrmOutput("City")]
        public string OutputCity
        {
            get { return (string)GetValue(OutputCityProperty); }
            set { SetValue(OutputCityProperty, value); }
        }

        [CrmOutput("Country Or Region")]
        public string OutputCountry
        {
            get { return (string)GetValue(OutputCountryProperty); }
            set { SetValue(OutputCountryProperty, value); }
        }

        [CrmOutput("Latitude")]
        public CrmFloat OutputLatitude
        {
            get { return (CrmFloat)GetValue(OutputLatitudeProperty); }
            set { SetValue(OutputLatitudeProperty, value); }
        }

        [CrmOutput("Line 1")]
        public string OutputLine1
        {
            get { return (string)GetValue(OutputLine1Property); }
            set { SetValue(OutputLine1Property, value); }
        }

        [CrmOutput("Longitude")]
        public CrmFloat OutputLongitude
        {
            get { return (CrmFloat)GetValue(OutputLongitudeProperty); }
            set { SetValue(OutputLongitudeProperty, value); }
        }

        [CrmOutput("Multiple Address Found")]
        public CrmBoolean OutputMultipleFound
        {
            get { return (CrmBoolean)GetValue(OutputMultipleFoundProperty); }
            set { SetValue(OutputMultipleFoundProperty, value); }
        }

        [CrmOutput("Postal Code")]
        public string OutputPostalCode
        {
            get { return (string)GetValue(OutputPostalCodeProperty); }
            set { SetValue(OutputPostalCodeProperty, value); }
        }

        [CrmOutput("State Or Province")]
        public string OutputState
        {
            get { return (string)GetValue(OutputStateProperty); }
            set { SetValue(OutputStateProperty, value); }
        }

        protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext)
        {
            // Reset Outputs
            OutputLatitude = new CrmFloat();
            OutputLongitude = new CrmFloat();
            OutputLine1 = String.Empty;
            OutputCity = String.Empty;
            OutputState = String.Empty;
            OutputPostalCode = String.Empty;
            OutputMultipleFound = new CrmBoolean {Value = false};

            var key = BingKey;
            if (String.IsNullOrEmpty(key) || key.ToLower() == "registry")
            {
                key = GetAPIKeyFromRegistry();
            }

            // Create Bing Maps Request
            var bingRequest = new GeocodeRequest
                              {
                                  Credentials = new Credentials {ApplicationId = key},
                                  Query = AddressLine1 + ", " +
                                          AddressCity + ", " +
                                          AddressState + ", " +
                                          AddressPostalCode + ", " +
                                          AddressCountry
                              };

            // Filter for High Confidence
            var filters = new ConfidenceFilter[1];
            filters[0] = new ConfidenceFilter {MinimumConfidence = Confidence.High};
            bingRequest.Options = new GeocodeOptions {Filters = filters};

            // Create Client
            GeocodeServiceClient bingClient = null;
            try
            {
                var geoBinding = new BasicHttpBinding(BasicHttpSecurityMode.None)
                                 {
                                     Name = "BasicHttpBinding_IGeocodeService",
                                     CloseTimeout = new TimeSpan(0, 1, 0),
                                     OpenTimeout = new TimeSpan(0, 1, 0),
                                     ReceiveTimeout = new TimeSpan(0, 10, 0),
                                     SendTimeout = new TimeSpan(0, 1, 0),
                                     AllowCookies = false,
                                     BypassProxyOnLocal = false,
                                     HostNameComparisonMode = HostNameComparisonMode.StrongWildcard,
                                     MaxBufferSize = 65536,
                                     MaxBufferPoolSize = 524288,
                                     MaxReceivedMessageSize = 65536,
                                     MessageEncoding = WSMessageEncoding.Text,
                                     TextEncoding = Encoding.UTF8,
                                     TransferMode = TransferMode.Buffered,
                                     UseDefaultWebProxy = true
                                 };

                var geoEA =
                    new EndpointAddress("http://dev.virtualearth.net/webservices/v1/geocodeservice/GeocodeService.svc");

                bingClient = new GeocodeServiceClient(geoBinding, geoEA);

                var bingResponse = bingClient.Geocode(bingRequest);

                if (bingResponse.Results != null &#038;&#038; bingResponse.Results.Length > 0)
                {
                    if (bingResponse.Results.Length > 1)
                    {
                        OutputMultipleFound.Value = true;
                    }

                    var bingResult = bingResponse.Results[0];

                    if (bingResult.Locations != null &#038;&#038; bingResult.Locations.Length > 0)
                    {
                        var bingLocation = bingResult.Locations[0];
                        OutputLatitude.Value = bingLocation.Latitude;
                        OutputLongitude.Value = bingLocation.Longitude;
                    }

                    var bingAddress = bingResult.Address;

                    OutputLine1 = bingAddress.AddressLine;
                    OutputPostalCode = bingAddress.PostalCode;
                    OutputCountry = bingAddress.CountryRegion;

                    OutputCity = String.IsNullOrEmpty(bingAddress.PostalTown)
                                     ? bingAddress.Locality
                                     : bingAddress.PostalTown;
                    OutputState = String.IsNullOrEmpty(bingAddress.AdminDistrict)
                                      ? bingAddress.District
                                      : bingAddress.AdminDistrict;
                }
            }
            catch (Exception ex)
            {
                throw new WorkflowTerminatedException(
                    "There was an error openning the connection to Bing Maps.", ex);
            }
            finally
            {
                // Close the client
                if (bingClient != null)
                {
                    bingClient.Close();
                }
            }

            return base.Execute(executionContext);
        }

        private static string GetAPIKeyFromRegistry()
        {
            // Opening the registry key
            var key = Registry.LocalMachine;
            if (key != null)
            {
                key = key.OpenSubKey("Software\\Microsoft Geocoder");
            }

            return key != null ? key.GetValue("APIKey").ToString() : null;
        }
    }
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://mscrmblogger.com/2010/05/20/geocode_with_bing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Editing an Advanced Find Query in Excel</title>
		<link>http://mscrmblogger.com/2009/10/12/editing-an-advanced-find-query-in-excel/</link>
		<comments>http://mscrmblogger.com/2009/10/12/editing-an-advanced-find-query-in-excel/#comments</comments>
		<pubDate>Mon, 12 Oct 2009 11:28:44 +0000</pubDate>
		<dc:creator>Carlton Colter</dc:creator>
				<category><![CDATA[Addons]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Integration]]></category>
		<category><![CDATA[advanced find]]></category>
		<category><![CDATA[crm]]></category>
		<category><![CDATA[crm 4]]></category>
		<category><![CDATA[crm4]]></category>
		<category><![CDATA[excel]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[microsoft dynamics CRM 4]]></category>

		<guid isPermaLink="false">http://mscrmblogger.com/?p=161</guid>
		<description><![CDATA[Here is a video tutorial of how to take a case advanced find, edit the query, troubleshoot errors in SQL Management Studio, and update your excel query.]]></description>
			<content:encoded><![CDATA[<p>Here is a video tutorial of how to take a case advanced find, edit the query, troubleshoot errors in SQL Management Studio, and update your excel query.</p>
<p><object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/tr1FXu-tVHM&#038;hl=en&#038;fs=1&#038;ap=%2526fmt%3D22"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/tr1FXu-tVHM&#038;hl=en&#038;fs=1&#038;ap=%2526fmt%3D22" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object></p>
<p>The steps are:</p>
<ol>
<li>Run an advanced find in CRM</li>
<li>Export it to Excel as a Dynamic Worksheet</li>
<li>Open it, save it as an excel file.</li>
<li>In Excel 2007, Click on Data in the ribbon, then Connections.</li>
<li>Click Properties</li>
<li>Click on Definition tab, edit the query</li>
<li>Click ok, then click close</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://mscrmblogger.com/2009/10/12/editing-an-advanced-find-query-in-excel/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>QueueItem RSS &#8211; An Example Of CRM RSS</title>
		<link>http://mscrmblogger.com/2009/09/30/queueitem-rss-an-example-of-crm-rss/</link>
		<comments>http://mscrmblogger.com/2009/09/30/queueitem-rss-an-example-of-crm-rss/#comments</comments>
		<pubDate>Wed, 30 Sep 2009 20:53:11 +0000</pubDate>
		<dc:creator>Carlton Colter</dc:creator>
				<category><![CDATA[Addons]]></category>
		<category><![CDATA[crm]]></category>
		<category><![CDATA[crm 4]]></category>
		<category><![CDATA[crm sdk]]></category>
		<category><![CDATA[crm4]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[microsoft dynamics CRM 4]]></category>
		<category><![CDATA[query]]></category>
		<category><![CDATA[questions]]></category>

		<guid isPermaLink="false">http://mscrmblogger.com/?p=143</guid>
		<description><![CDATA[The Notification Accelerator on Codeplex does not offer a queueitem RSS feed.  I'm not sure why, but here is a simple solution to display an RSS feed.  It defaults to the current user's queues, but if the q=blah is specified in address then all queueitems in any queue with blah in it will be displayed.]]></description>
			<content:encoded><![CDATA[<p>The Notification Accelerator on Codeplex does not offer a queueitem RSS feed.  I&#8217;m not sure why, but here is a simple solution to display an RSS feed.  It defaults to the current user&#8217;s queues, but if the q=blah is specified in address then all queueitems in any queue with blah in it will be displayed.  Please feel free to post your comments.  I did not spend a lot of time on this and I think sql would be quicker.  If you find a method that is quick and easy that displays the queue name and queue items, please post it.</p>
<p>crmsdk is my http://crm/MSCrmServices/2007/CrmService.asmx web reference</p>
<pre name="code" class="csharp">
using System;
using System.Net;
using System.Text;
using System.Web.UI;
using System.Xml;
using CRMQIRSS.crmsdk;

namespace CRMQIRSS
{
    public partial class _Default : Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            var QueueName = String.Empty;

            try
            {
                QueueName = Request[&quot;q&quot;];
            }
            catch
            {
                // Ignore Errors
            }

            // Clear Any Response
            Response.Clear();
            Response.ContentType = &quot;text/xml&quot;;

            var xtwFeed = new XmlTextWriter(Response.OutputStream, Encoding.UTF8);
            xtwFeed.WriteStartDocument();
            // Setup Feed

            xtwFeed.WriteStartElement(&quot;rss&quot;);
            xtwFeed.WriteAttributeString(&quot;version&quot;, &quot;2.0&quot;);

            // Setup Channel
            xtwFeed.WriteStartElement(&quot;channel&quot;);
            xtwFeed.WriteElementString(&quot;title&quot;, QueueName);
            xtwFeed.WriteElementString(&quot;link&quot;, &quot;http://www.mscrmblogger.com&quot;);
            xtwFeed.WriteElementString(&quot;ttl&quot;, &quot;5&quot;);
            xtwFeed.WriteElementString(&quot;description&quot;, &quot;The most technical and solution rich CRM blog.&quot;);
            xtwFeed.WriteElementString(&quot;copyright&quot;, &quot;Copyright 2009 mscrmblogger.com. All rights reserved.&quot;);

            // Get the Dataset
            BusinessEntityCollection becQueueItems;
            if (String.IsNullOrEmpty(QueueName))
            {
                becQueueItems = GetQueueItemsByCurrentUser();
            }
            else
            {
                becQueueItems = GetQueueItemsByName(QueueName);
            }

            foreach (var be in becQueueItems.BusinessEntities)
            {
                var qi = (queueitem) be;

                var description = &quot;Created: &quot; + Convert.ToDateTime(qi.createdon.Value).ToString(&quot;f&quot;);

                xtwFeed.WriteStartElement(&quot;item&quot;);

                xtwFeed.WriteElementString(&quot;title&quot;, qi.title);

                xtwFeed.WriteElementString(&quot;description&quot;, description);

                String objecttypecode;
                switch (qi.objecttypecode.Value)
                {
                    case &quot;incident&quot;:
                        objecttypecode = &quot;112&quot;;
                        break;
                    case &quot;task&quot;:
                        objecttypecode = &quot;4212&quot;;
                        break;
                    case &quot;phonecall&quot;:
                        objecttypecode = &quot;4202&quot;;
                        break;
                    case &quot;letter&quot;:
                        objecttypecode = &quot;4207&quot;;
                        break;
                    case &quot;serviceappointment&quot;:
                        objecttypecode = &quot;4214&quot;;
                        break;
                    case &quot;fax&quot;:
                        objecttypecode = &quot;4204&quot;;
                        break;
                    case &quot;email&quot;:
                        objecttypecode = &quot;4202&quot;;
                        break;
                    case &quot;campaignactivity&quot;:
                        objecttypecode = &quot;4402&quot;;
                        break;
                    case &quot;campaignresponse&quot;:
                        objecttypecode = &quot;4401&quot;;
                        break;
                    default:
                        objecttypecode = &quot;0&quot;;
                        break;
                }

                xtwFeed.WriteElementString(&quot;link&quot;,
                                           &quot;http://crm/CRMReports/viewer/drillopen.aspx?ID=&quot; + qi.objectid.Value +
                                           &quot;&amp;OTC=&quot; + objecttypecode);

                xtwFeed.WriteElementString(&quot;pubDate&quot;, Convert.ToDateTime(qi.enteredon.Value).ToString(&quot;f&quot;));

                xtwFeed.WriteElementString(&quot;author&quot;, qi.createdby.name);

                //TODO: Lookup the queue...  this would be quicker (and easier) with SQL...
                //xtwFeed.WriteElementString(&quot;category&quot;, &quot;queue/&quot; + qi.queueid);

                xtwFeed.WriteEndElement();
            }

            // Close all tags
            xtwFeed.WriteEndElement();
            xtwFeed.WriteEndElement();
            xtwFeed.WriteEndDocument();
            xtwFeed.Flush();
            xtwFeed.Close();
            Response.End();
        }

        private CrmService GetCrmServiceConnection(String Organization)
        {
            var token = new CrmAuthenticationToken();
            token.AuthenticationType = 0; //AD
            token.OrganizationName = Organization;

            var crmService = new CrmService();
            crmService.CrmAuthenticationTokenValue = token;
            crmService.Credentials = CredentialCache.DefaultCredentials;

            return crmService;
        }

        private BusinessEntityCollection FetchDataSet(string fetchXml)
        {
            var service = GetCrmServiceConnection(&quot;OrganizationXYZ&quot;);

            var request = new FetchXmlToQueryExpressionRequest();
            request.FetchXml = fetchXml;

            var response = (FetchXmlToQueryExpressionResponse) service.Execute(request);

            var items = service.RetrieveMultiple(response.Query);

            return items;
        }

        private BusinessEntityCollection GetQueueItemsByName(String queueName)
        {
            var fetchXML = &quot;&lt;fetch mapping=\&quot;logical\&quot; count=\&quot;50\&quot; distinct=\&quot;true\&quot;&gt;&quot; +
                           &quot;  &lt;entity name=\&quot;queueitem\&quot;&gt;&quot; +
                           &quot;    &lt;all-attributes /&gt;&quot; +
                           &quot;    &lt;link-entity name=\&quot;queue\&quot; from=\&quot;queueid\&quot; to=\&quot;queueid\&quot;&gt;&quot; +
                           &quot;      &lt;attribute name=\&quot;name\&quot; /&gt;&quot; +
                           &quot;      &lt;filter&gt;&quot; +
                           &quot;        &lt;condition attribute=\&quot;name\&quot; operator=\&quot;like\&quot; value=\&quot;%&quot; +
                           queueName +
                           &quot;%\&quot; /&gt;&quot; +
                           &quot;      &lt;/filter&gt;&quot; +
                           &quot;    &lt;/link-entity&gt;&quot; +
                           &quot;  &lt;/entity&gt;&quot; +
                           &quot;&lt;/fetch&gt;&quot;;

            return FetchDataSet(fetchXML);
        }

        private BusinessEntityCollection GetQueueItemsByCurrentUser()
        {
            var fetchXML = &quot;&lt;fetch mapping=\&quot;logical\&quot; count=\&quot;50\&quot; distinct=\&quot;true\&quot;&gt;&quot; +
                           &quot;  &lt;entity name=\&quot;queueitem\&quot;&gt;&quot; +
                           &quot;    &lt;all-attributes /&gt;&quot; +
                           &quot;    &lt;link-entity name=\&quot;queue\&quot; from=\&quot;queueid\&quot; to=\&quot;queueid\&quot;&gt;&quot; +
                           &quot;      &lt;attribute name=\&quot;name\&quot; /&gt;&quot; +
                           &quot;      &lt;filter&gt;&quot; +
                           &quot;        &lt;condition attribute=\&quot;primaryuserid\&quot; operator=\&quot;eq-userid\&quot; /&gt;&quot; +
                           &quot;      &lt;/filter&gt;&quot; +
                           &quot;    &lt;/link-entity&gt;&quot; +
                           &quot;  &lt;/entity&gt;&quot; +
                           &quot;&lt;/fetch&gt;&quot;;

            return FetchDataSet(fetchXML);
        }
    }
}
</pre>
<p>Total time spent on this: 45 minutes</p>
]]></content:encoded>
			<wfw:commentRss>http://mscrmblogger.com/2009/09/30/queueitem-rss-an-example-of-crm-rss/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Bulk Delete System Jobs</title>
		<link>http://mscrmblogger.com/2009/02/12/bulk-delete-system-jobs/</link>
		<comments>http://mscrmblogger.com/2009/02/12/bulk-delete-system-jobs/#comments</comments>
		<pubDate>Thu, 12 Feb 2009 05:59:37 +0000</pubDate>
		<dc:creator>Carlton Colter</dc:creator>
				<category><![CDATA[Addons]]></category>
		<category><![CDATA[bulk delete]]></category>
		<category><![CDATA[crm4]]></category>
		<category><![CDATA[log]]></category>
		<category><![CDATA[system jobs]]></category>
		<category><![CDATA[workflow]]></category>

		<guid isPermaLink="false">http://mscrmblogger.com/?p=34</guid>
		<description><![CDATA[CRM 4.0has an endless amounts of system job logs.  We perform automatic actions on a lot of entities, but we don't need the log of those automatic actions beyond the end of that working day if it was Canceled or Completed Successfully.  Now we can setup a custom bulk deletion job that won't keep those successful entries.]]></description>
			<content:encoded><![CDATA[<p>CRM 4.0has an endless amounts of system job logs.  We perform automatic actions on a lot of entities, but we don&#8217;t need the log of those automatic actions beyond the end of that working day if it was Canceled or Completed Successfully.  Unfortunately, setting up a bulk delete task for system job logs is not as easy as setting up other bulk delete jobs.  I modified the code from <a href="http://blogs.msdn.com/crm/archive/2008/11/13/leveraging-bulk-delete-jobs-to-manage-system-job-log-records.aspx" target="_new">Sean McNellis&#8217; blog entry on leveraging bulk delete jobs to manage system job log records</a>.</p>
<p><b>Below is my code (which is a modified version of the runBulkDelete from the <a href="http://code.msdn.microsoft.com/crmbulkdelete/Release/ProjectReleases.aspx?ReleaseId=1795" target="_new">Microsoft Bulk Delete Sample</a> for deleting successfully completed or canceled jobs:</b></p>
<pre name="code" class="csharp">
        static void runBulkDeleteAsyncoperations(CrmService service)
        {
            // Create a query expression using the QueryExpressionHelper
            QueryExpressionHelper expression = new QueryExpressionHelper("asyncoperation");
            expression.Columns.AddColumn("asyncoperationid");
            expression.Criteria.Conditions.AddCondition("statecode",
                        ConditionOperator.Equal,
                        (int)AsyncOperationState.Completed);
            expression.Criteria.Conditions.AddCondition("statuscode",
                        ConditionOperator.Equal,
                        new object[]{(int)AsyncOperationStatus.Canceled,(int)AsyncOperationStatus.Succeeded});
            Guid[] emptyRecipients = new Guid[0];
            BulkDeleteRequest request = new BulkDeleteRequest();
            request.JobName = "Bulk Delete Successfully Completed or Canceled Asyncoperations and Workflow Logs";
            request.QuerySet = new QueryBase[] { expression.Query };
            request.ToRecipients = emptyRecipients;
            request.CCRecipients = emptyRecipients;
            request.SendEmailNotification = false;
            request.RecurrencePattern = "FREQ=DAILY;INTERVAL=1;";
            request.StartDateTime = CrmDateTime.Now;

            BulkDeleteResponse response = (BulkDeleteResponse)service.Execute(request);

            Console.WriteLine("Bulk delete job with id: {0} has been created", response.JobId);
        }
</pre>
<p>Their code examples use a month time span, and if you are trying to delete everything older than 3 days, then you need to build an executable and schedule it to run daily to create the bulk deletion job.  You will also need the following filter to be added to the code, and set the RecurrencePattern equal to string.empty.</p>
<pre name="code" class="csharp">
expression.Criteria.Conditions.AddCondition("completedon", ConditionOperator.OnOrBefore, DateTime.Now.AddDays(-3).ToString("yyyy-MM-dd"));
</pre>
<p>If by some chance you are curious about creating Bulk Delete Jobs in general, <a href="http://blogs.msdn.com/crm/archive/2008/04/24/bulk-record-deletion-in-microsoft-crm-online.aspx" target="_new">check out msdn blog entry</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://mscrmblogger.com/2009/02/12/bulk-delete-system-jobs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
