Friday, September 23, 2011

How to add color to a Microsoft CRM 2011 Form Picklist

Add color to target picklist is a very simple task. I will show you an example on Task form, Priority Picklist.
It has three options: Low, Normal, High.
Let’s add colors for them: Yellow, Green and Red.

Simply add OnLoad event:

function AddColorToPriority()
{
crmForm.all["prioritycode"][0].style.background = "#FFF380"; // Low => Yellow
crmForm.all["prioritycode"][1].style.background = "#5EFB6E"; // Normal => Green
crmForm.all["prioritycode"][2].style.background = "#E55451"; // High => Red
}


Here is other way to implement it:

function AddColorToPrioritySecond()
{
crmForm.all.prioritycode[0].style.background = "yellow"; // Low => Yellow
crmForm.all.prioritycode[1].style.background = "green"; // Normal => Green
crmForm.all.prioritycode[2].style.background = "red"; // High => Red
}

Monday, September 19, 2011

Get a list of System and User Dashboards in CRM 2011

You can get a complete list of System and User Dashboard by:

public void InitializeDashboardList()
{
     this.GetSystemDashboard();
     this.GetUserDashboard();
}

private void GetSystemDashboard()
{
if (!User.HasPrivilege("systemform", AccessRights.ReadAccess, (IOrganizationContext)UserInformation.Current))
return;
var systemdashboard = this.RetrieveDashboard("systemform", new string[4]
{
"formid",
"name",
"isdefault",
"description"
});
}

private void GetUserDashboard()
{
if (!User.HasPrivilege("userform", AccessRights.ReadAccess, (IOrganizationContext)UserInformation.Current))
return;
var userdashboard = this.RetrieveDashboard("userform", new string[3]
{
"userformid",
"name",
"description"
});
}

private ApplicationEntityCollection RetrieveDashboard(string logicalName, string[] columns)
{
     QueryExpression query = new QueryExpression(logicalName);
     query.ColumnSet.AddColumns(columns);
     query.Criteria.AddCondition("type", ConditionOperator.Equal, (object)0);
     query.Orders.Add((object)new OrderExpression("name", OrderType.Ascending));
     return DataSource.RetrieveMultiple(query, (IOrganizationContext)UserInformation.Current);
}

List of Microsoft CRM 2011 Web Services

List of Web Services:

http://demo:7777/AppWebServices/ActivitiesWebService.asmx

http://demo:7777/AppWebServices/AdvancedFind.asmx

http://demo:7777/AppWebServices/Annotation.asmx

http://demo:7777/AppWebServices/AppGridWebService.asmx

http://demo:7777/AppWebServices/AssociateRecords.asmx

Wednesday, September 14, 2011

Search all columns of all tables in a MS CRM 2011 database for a keyword.


Here is the complete stored procedure code:
CREATE PROC SearchKeywordInAllCRMTables
(
@SearchKeyword nvarchar(100)
)
AS
BEGIN

CREATE TABLE #SearchResults (ColumnName nvarchar(370), ColumnValue nvarchar(3630))
SET NOCOUNT ON
DECLARE @TableName nvarchar(256), @ColumnName nvarchar(128), @TempKeyword nvarchar(110)

Wednesday, September 7, 2011

Add specific access Role for Dashboard in the CRM 2011.


First we need to find out RoleID. To do that simply run Microsoft SQL Management Studio and execute following query:

SELECT [Name],[RoleIdUnique] FROM [OrganizationName_MSCRM].[dbo].[Role]

You will get something like: