<?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; advanced find</title>
	<atom:link href="http://mscrmblogger.com/tag/advanced-find/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>Adding the queue name to a saved advanced find for cases (incidents)</title>
		<link>http://mscrmblogger.com/2010/02/18/adding-the-queue-name-to-a-saved-advanced-find-for-cases-incidents/</link>
		<comments>http://mscrmblogger.com/2010/02/18/adding-the-queue-name-to-a-saved-advanced-find-for-cases-incidents/#comments</comments>
		<pubDate>Thu, 18 Feb 2010 18:56:43 +0000</pubDate>
		<dc:creator>Carlton Colter</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Scoperta]]></category>
		<category><![CDATA[advanced find]]></category>
		<category><![CDATA[cases]]></category>
		<category><![CDATA[crm4]]></category>
		<category><![CDATA[find]]></category>
		<category><![CDATA[incidents]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[microsoft dynamics CRM 4]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://mscrmblogger.com/?p=212</guid>
		<description><![CDATA[<p>Unfortunately, CRM does not currently support adding the queue to a case advanced find.  However, that doesn't mean it can't be done.  Follow the steps in this article to modify your fetchXML and your layoutXML to have the queue name show up in the advanced find.</p>]]></description>
			<content:encoded><![CDATA[<p>Unfortunately, CRM does not currently support adding the queue to a case advanced find.  However, that doesn&#8217;t mean it can&#8217;t be done.</p>
<p>Please note, that this is not a supported modification or change.</p>
<p>Follow the steps below to modify your fetchXML and your layoutXML to have the queue name show up in the advanced find. You can even update the name in the UserQueryBase to rename your advanced find to something better.</p>
<ol>
<li>Create your advanced find, setup your filters etc.</li>
<li>Save your advanced find (name it something unique)</li>
<li>Get the guid of your advanced find (using open pop-ups in a new tab or using a select statement to look it up in the db.
<pre name="code" class="sql">
SELECT UserQueryID FROM UserQueryBase WHERE Name='Cases (w/Queue Name) - IT Example'
</pre>
</li>
<li>Then using the id, execute the following code to add the queue name:
<pre name="code" class="sql">
UPDATE UserQueryBase SET
FetchXml = REPLACE(FetchXml,'&lt;/entity&gt;',
'&lt;link-entity name=&quot;queueitem&quot; from=&quot;objectid&quot; to=&quot;incidentid&quot; visible=&quot;false&quot; link-type=&quot;outer&quot; alias=&quot;qi&quot;&gt;
&lt;link-entity name=&quot;queue&quot; from=&quot;queueid&quot; to=&quot;queueid&quot; visible=&quot;false&quot; link-type=&quot;outer&quot; alias=&quot;Q&quot;&gt;
&lt;attribute name=&quot;name&quot;/&gt;&lt;/link-entity&gt;&lt;/link-entity&gt;&lt;/entity&gt;')
,LayoutXML = REPLACE(LayoutXml,'&lt;/row&gt;',
'&lt;cell name=&quot;Q.name&quot; width=&quot;200&quot; disableSorting=&quot;0&quot;/&gt;&lt;/row&gt;')
-- Make sure to change the UserQueryID
WHERE UserQueryID='71F94C46-F217-DF11-A241-0050569B4FF3'
</pre>
</li>
<li>If you have your advanced find window open, close and reopen it before trying to run it and see the &quot;Q.name&quot; column.</li>
</ol>
<p>If you have any problems or questions, let me know.  Again this is setup to work on advanced find for cases, I&#8217;m sure it could be modified for other queue-able entities.</p>
]]></content:encoded>
			<wfw:commentRss>http://mscrmblogger.com/2010/02/18/adding-the-queue-name-to-a-saved-advanced-find-for-cases-incidents/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>Increasing Paging Limits</title>
		<link>http://mscrmblogger.com/2009/02/10/paging-limits/</link>
		<comments>http://mscrmblogger.com/2009/02/10/paging-limits/#comments</comments>
		<pubDate>Tue, 10 Feb 2009 14:37:17 +0000</pubDate>
		<dc:creator>Carlton Colter</dc:creator>
				<category><![CDATA[Scoperta]]></category>
		<category><![CDATA[advanced find]]></category>
		<category><![CDATA[crm4]]></category>
		<category><![CDATA[lists]]></category>
		<category><![CDATA[paging]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://mscrmblogger.com/?p=31</guid>
		<description><![CDATA[Paging Limits control how many items show up on the list pages in crm.  Most notably advanced finds.  I like to be able to display a lot of information, and I need to be able to run operations on more than 250 items.  Using the following SQL query I was able to [...]]]></description>
			<content:encoded><![CDATA[<p>Paging Limits control how many items show up on the list pages in crm.  Most notably advanced finds.  I like to be able to display a lot of information, and I need to be able to run operations on more than 250 items.  Using the following SQL query I was able to increase my paging limit to 1000.
</p>
<pre name="code" class="sql">
UPDATE UserSettings SET PagingLimit=1000 WHERE SystemUserId IN
(Select SystemUserId from SystemUserBase WHERE FullName like 'Carlton%')
</pre>
]]></content:encoded>
			<wfw:commentRss>http://mscrmblogger.com/2009/02/10/paging-limits/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CRM 4 UserQuery Privileges for System Administrators</title>
		<link>http://mscrmblogger.com/2009/02/04/crm-4-userquery-privileges-for-system-administrators/</link>
		<comments>http://mscrmblogger.com/2009/02/04/crm-4-userquery-privileges-for-system-administrators/#comments</comments>
		<pubDate>Wed, 04 Feb 2009 15:30:27 +0000</pubDate>
		<dc:creator>Carlton Colter</dc:creator>
				<category><![CDATA[Scoperta]]></category>
		<category><![CDATA[advanced find]]></category>
		<category><![CDATA[assign]]></category>
		<category><![CDATA[crm4]]></category>
		<category><![CDATA[permissions]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[userquery]]></category>

		<guid isPermaLink="false">http://mscrmblogger.com/?p=5</guid>
		<description><![CDATA[The CRM 4 System Administrators group does not have access to assign other people's saved advanced finds (user queries). I have created a single aspx page that uses the CRM SDK to allow a system administrator to assign any user's saved view to another user.]]></description>
			<content:encoded><![CDATA[<p>One of the problems I noticed in a recent upgrade to CRM 4 was that the System Administrators group did not have access to assign other people&#8217;s saved advanced finds (user queries). This is extremely annoying because I have a single aspx page that uses the CRM SDK to allow a system administrator to move any saved view from being owned by one person to another.
</p>
<p>Saved views are great for the organization, departments, and teams, but when a team uses them, often times they have someone create and share the views, then they leave the company or move to a different group within the company. They either can&#8217;t or no longer wish to be responsible for the advanced finds they have created and shared out with their fellow CRM users.</p>
<p>My custom page allows me to assign those views to someone else, allowing them to move the responisibility to another CRM user.</p>
<p>To update the CRM privileges to allow System Administrators full access (except for read) to all views, you can run the following sql code against the database.</p>
<p><strong>SQL Code:</strong></p>
<pre name="code" class="sql">UPDATE RolePrivileges SET PrivilegeDepthMask=128 WHERE RolePrivilegeId IN
(
  SELECT RolePrivilegeId FROM RolePrivileges r
  INNER JOIN PrivilegeBase pb ON r.privilegeid=pb.privilegeid
  INNER JOIN RoleBase rb ON r.roleid = rb.roleid
  WHERE pb.Name in
    ('prvAssignUserQuery',
     'prvShareUserQuery',
     'prvWriteUserQuery',
     'prvDeleteUserQuery',
     'prvCreateUserQuery'
    )
    AND rb.Name = 'System Administrator'
)</pre>
<p>The code for reassigning objects is really straight forward, it uses sql to get the lists, then uses the sdk to assign the items to other users.  It doesn&#8217;t fail because of the sql modification above.</p>
<p><b>ASP.Net Code</b></p>
<pre name="code" class="html">
&lt;%@ Page Language="C#" AutoEventWireup="true" CodeBehind="reassign.aspx.cs" Inherits="mst_Support.userquery.reassign" %&gt;

&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;head runat="server"&gt;
    &lt;title&gt;Untitled Page&lt;/title&gt;
    &lt;link href="../css/support.css" rel="stylesheet" type="text/css" /&gt;
&lt;/head&gt;
&lt;body&gt;
    &lt;form id="form1" runat="server"&gt;
    &lt;div align="center"&gt;
        &lt;asp:ScriptManager ID="smgr" runat="server"&gt;
        &lt;/asp:ScriptManager&gt;
        &lt;br /&gt;
        &lt;b&gt;Source User:&lt;/b&gt;
        &lt;asp:DropDownList ID="User_Src" runat="server" DataSourceID="crm_SystemUsers" DataTextField="FullName"
            DataValueField="SystemUserId" AutoPostBack="True" OnSelectedIndexChanged="User_Src_SelectedIndexChanged"&gt;
        &lt;/asp:DropDownList&gt;
        &lt;br /&gt;
        &lt;asp:UpdatePanel ID="upnQueries" runat="server" UpdateMode="Conditional"&gt;
            &lt;ContentTemplate&gt;
                &lt;br /&gt;
                &lt;b&gt;Saved Advanced Finds:&lt;br /&gt;
                &lt;/b&gt;
                &lt;asp:ListBox ID="QueueList" runat="server" SelectionMode="Multiple" Rows="15"&gt;&lt;/asp:ListBox&gt;
            &lt;/ContentTemplate&gt;
            &lt;Triggers&gt;
                &lt;asp:AsyncPostBackTrigger ControlID="User_Src" EventName="SelectedIndexChanged" /&gt;
            &lt;/Triggers&gt;
        &lt;/asp:UpdatePanel&gt;
        &lt;br /&gt;
        &lt;b&gt;Target User:&lt;/b&gt;
        &lt;asp:DropDownList ID="User_Target" runat="server"
            DataSourceID="crm_SystemUsers" DataTextField="FullName"
            DataValueField="SystemUserId"&gt;
        &lt;/asp:DropDownList&gt;
        &lt;br /&gt;
        &lt;br /&gt;
        &lt;asp:Button ID="Assign" runat="server" onclick="Assign_Click" Text="Assign" /&gt;
        &lt;br /&gt;
        &lt;br /&gt;
        &lt;asp:Label ID="lblResponse" runat="server"&gt;&lt;/asp:Label&gt;
        &lt;br /&gt;
        &lt;br /&gt;
        &lt;asp:SqlDataSource ID="crm_SystemUsers" runat="server" ConnectionString="&lt;%$ ConnectionStrings:crm_db %&gt;"
            SelectCommand="SELECT [SystemUserId], [FullName] FROM [SystemUserBase] WHERE ([IsDisabled] = @IsDisabled) ORDER BY [FullName]"
            ProviderName="&lt;%$ ConnectionStrings:crm_db.ProviderName %&gt;"&gt;
            &lt;SelectParameters&gt;
                &lt;asp:Parameter DefaultValue="false" Name="IsDisabled" Type="Boolean" /&gt;
            &lt;/SelectParameters&gt;
        &lt;/asp:SqlDataSource&gt;
    &lt;/div&gt;
    &lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p><b>C-Sharp code</b></p>
<pre name="code" class="csharp">using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using mst_Support.crmsdk;
using System.Web.Services.Protocols;
using System.Web.Configuration;

namespace mst_Support.userquery
{
    public partial class reassign : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        public void AssignUserQuery(string queryid, string userid)
        {
            try
            {
                    CrmAuthenticationToken token = new CrmAuthenticationToken();
                    token.AuthenticationType = 0; //AD
                    token.OrganizationName = "Your Organization"; //Could retrieve it.

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

                    //crmService.Credentials = System.Net.CredentialCache.DefaultCredentials;

                    SecurityPrincipal newowner = new SecurityPrincipal();
                    newowner.Type = SecurityPrincipalType.User;
                    newowner.PrincipalId = new Guid(userid);

                    TargetOwnedUserQuery query = new TargetOwnedUserQuery();
                    query.EntityId = new Guid(queryid);

                    // Create the request object.
                    AssignRequest assign = new AssignRequest();

                    // Set the properties of the request object.
                    assign.Assignee = newowner;
                    assign.Target = query;

                    AssignResponse assignResponse = (AssignResponse)crmService.Execute(assign);
            }
            catch (SoapException ex)
            {
                lblResponse.Text += "&lt;b&gt;Error: &lt;/b&gt;" +ex.ToString() +
                                    "&lt;br /&gt;&lt;br /&gt;\r\n";
                lblResponse.Text += "&lt;b&gt;Inner Detail: &lt;/b&gt;" + ex.Detail.InnerText +
                                    "&lt;br /&gt;&lt;br /&gt;\r\n";
                lblResponse.Text += "&lt;b&gt;InnerException: &lt;/b&gt;" + ex.InnerException.ToString() +
                                    "&lt;br /&gt;&lt;br /&gt;\r\n";
                lblResponse.Text += "&lt;b&gt;StackTrace: &lt;/b&gt;" + ex.StackTrace.ToString() +
                                    "&lt;br /&gt;&lt;br /&gt;\r\n";
            }
        }

        protected void User_Src_SelectedIndexChanged(object sender, EventArgs e)
        {
            string query = "SELECT [Name], [UserQueryId] FROM [UserQueryBase] WHERE ([OwningUser] = '"+
                           User_Src.SelectedValue+"') ORDER BY [Name]";

            // Pull the crm_db connection string for the webconfig. (you could just replace this with
            // your connection string.

            SqlDataAdapter da = new SqlDataAdapter(query,
			   WebConfigurationManager.ConnectionStrings["crm_db"].ToString());

            DataSet ds = new DataSet();
            da.Fill(ds);

            QueueList.DataSource = ds.Tables[0].DefaultView;
            QueueList.DataTextField = "Name";
            QueueList.DataValueField = "UserQueryId";
            QueueList.DataBind();
            upnQueries.Update();
        }

        protected void Assign_Click(object sender, EventArgs e)
        {
            try
            {
                foreach (ListItem li in QueueList.Items)
                {
                    if (li.Selected)
                    {
                        lblResponse.Text += "Item: " + li.Value + " to: ";
                        lblResponse.Text += User_Target.SelectedValue + "&lt;br /&gt;";
                        AssignUserQuery(li.Value, User_Target.SelectedValue);
                    }
                }
                lblResponse.Text += "&lt;br /&gt;Moved Successfully";
                User_Src_SelectedIndexChanged(sender, e);
            }
            catch (Exception ex)
            {
                lblResponse.Text += ex.ToString() + "&lt; br/&gt;";
                lblResponse.Text += "Please report this error to internal systems.&lt;br /&gt;";
            }
        }

    }
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://mscrmblogger.com/2009/02/04/crm-4-userquery-privileges-for-system-administrators/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
