Thursday, March 5, 2015

MS CRM 2011 KB Article customization Issue.

Recently I have encountered some issue while customizing Kb Article Entity. I was doing following configuration in Article form.

1. Add Base Templet lookup to the form
2. Add status picklist to the form

What I notice while adding above fields to the form was that these fields became required and locked on the form.
Then what happened was, while creating new Article my ribbon was not loading.
We have tried to debug the JS and found that it’s breaking in below highlighted point. So I knew that something is wrong with the Base Template field which I added earlier.
n addition to that we have noticed that Submit, Approve,.. buttons were disabled on the form.
But it’s enabled in the main grid.
We knew that something was wrong with the fields we added to the Form, but now we cannot remove these two fields from the form as it became locked in the form, we consult Microsoft on this as it seems to be a product bug.

Then the Microsoft advise us to remove it manually form the customization xml. We followed the below steps then everything seems to be fine.

 • Create a New Solutions with Kb Article entity
 • Export the solutions as a unmanage and open customisation.xml
 • Edited the customization.xml and commented the control for kbarticletemplateid and statecode.
 • Saved the customization.xml file and zipped the solution.
 • Imported the solution back to the system.
 • Published the customization and issue was resolved by that.

Sunday, February 16, 2014

HOW TO: Use ASP to Force SSL for Specific Pages

Forcing ASP page to use https can be done in couple of ways, here I’m sharing how we can do this using code itself, rather than configuring IIS. Step 1: Create INC file with following code
if(Request.ServerVariables["SERVER_PORT"]== "80")
                string strSecureURL;
                strSecureURL = "https://";
                strSecureURL = strSecureURL + Request.ServerVariables["SERVER_NAME"];
                strSecureURL = strSecureURL + Request.ServerVariables["URL"];
Then save it as “” in web application root directory. Step 2: Add reference to INC file by adding below line:

Note: If you are using Master page, then you have to add this code inside

Step 3: Add https as new binding in IIS.

Wednesday, December 11, 2013

How To Obtain The Size Of All Tables In A SQL Server Database



-- DB size.
EXEC sp_spaceused

-- Table row counts and sizes.
    [name] NVARCHAR(128),
    [rows] CHAR(11),
    reserved VARCHAR(18), 
    data VARCHAR(18), 
    index_size VARCHAR(18),
    unused VARCHAR(18)

INSERT #t EXEC sp_msForEachTable 'EXEC sp_spaceused ''?''' 

FROM   #t

-- # of rows.
SELECT SUM(CAST([rows] AS int)) AS [rows]
FROM   #t

Reference :,guid,df930155-f60f-4f56-ab33-f1352ff091a1.aspx

Tuesday, August 13, 2013

CRM 2011: How to read Web resource from code

Following code snippet will help you to read content of the web resource.
/// Reads the CRM Web Resource by its unique name as a string

        public string ReadContent(string resourceName)
            byte[] byteArray = ReadBytes(resourceName);
            if (byteArray != null)
                return System.Text.Encoding.UTF8.GetString(byteArray);
            return string.Empty;            

/// Reads the CRM Web Resource by its unique name as a byte array
        public byte[] ReadBytes(string resourceName)
                WebResource webResource = new WebResource();

                QueryExpression query = new QueryExpression()
                    EntityName = "webresource",
                    ColumnSet = new ColumnSet("content"),
                    Criteria = new FilterExpression
                        FilterOperator = LogicalOperator.And,
                        Conditions = 
                            new ConditionExpression{AttributeName = "name", Operator = ConditionOperator.Equal, Values = { resourceName }}

                RetrieveMultipleRequest retrieveMultipleRequest = new RetrieveMultipleRequest { Query = query };

                RetrieveMultipleResponse retrieveMultipleResponse = (RetrieveMultipleResponse)service.Execute(retrieveMultipleRequest);

                if (retrieveMultipleResponse != null && retrieveMultipleResponse.EntityCollection != null && retrieveMultipleResponse.EntityCollection.Entities.Count > 0)
                    webResource = (WebResource)retrieveMultipleResponse.EntityCollection.Entities[0];

                    byte[] byteArray = Convert.FromBase64String(webResource.Content);

                    return byteArray;

            catch (Exception exception)

            return null;

Wednesday, July 31, 2013

CRM 2011 Views – Retrieve more than 5000 records

As you probably know, by default CRM view retrieve only 5000 records for the view, to retrieve more than 5000 records we can use following method, Note that this is an unsupported change. This will applied to all Organizations in the CRM.

IntColumn Value: Set to -1,

This will retrieve all records in the table.
UPDATE DeploymentProperties
SET IntColumn = '-1'
WHERE ColumnName = 'TotalRecordCountLimit'
After executing this query give a IIS Reset.

There is another way to change the registry value, But it will only applied to fetch XML, after you changed registry value still you receive only 5000 record in Entity grid.

Tuesday, July 30, 2013

NRIC(Singapore) Validation using Javascript

function IsValidNRIC(theNric) {
    var nric = [];
    nric.multiples = [2, 7, 6, 5, 4, 3, 2];

    if (theNric.length != 9) {
        alert('Invalid NRIC')
        return false;

    var total = 0, count = 0, numericNric;
    var first = theNric.charAt(0), last = theNric.charAt(theNric.length - 1);

    if (first != 'S' && first != 's') {
        alert('Invalid NRIC S');
        return false;
    /*Above is working*/

    numericNric = theNric.substr(1, theNric.length - 2);

    if (isNaN(numericNric)) {
        alert('Invalid NRIC Middle Not a number')
        return false

    if (numericNric != null) {
        while (numericNric != 0) {
            total += (numericNric % 10) * nric.multiples[nric.multiples.length - (1 + count++)];
            numericNric /= 10;
            numericNric = Math.floor(numericNric);

    var outputs;
    if (first == 'S') {
        outputs = ['J', 'Z', 'I', 'H', 'G', 'F', 'E', 'D', 'C', 'B', 'A'];

    if (first == 'T') {
        outputs = ['G', 'F', 'E', 'D', 'C', 'B', 'A', 'J', 'Z', 'I', 'H'];

    if (last != outputs[total % 11]) {
        alert('Invalid end Character')
        return false;

    nric.isNricValid = function (theNric) {
        if (!theNric || theNric == '') {
            return false;
    return true;

MS CRM 2011 KB Article customization Issue.

Recently I have encountered some issue while customizing Kb Article Entity. I was doing following configuration in Article form. 1. Add Ba...