Sunday, 15 November 2015

Allow only numbers in a text box


In most of web applications, we get requirement to allow only number in a textbox.

Here is the JavaScript for it, just call this method onKeyPressv Event.

   <SCRIPT language=Javascript>
       function isNumberPressed(evt) {
           var charCode = (evt.which) ? evt.which : event.keyCode
           if (charCode > 31 && (charCode < 48 || charCode > 57))
               return false;
           return true;
      <INPUT id="txtChar" onkeypress="return isNumberPressed(event)" type="text" name="txtChar">
Hope this helps.

Happy Coding

Saturday, 14 November 2015

This workflow job was canceled because the workflow that started it included an infinite loop.

In CRM, Workflow is one of the amazing things. If our workflow calls itself (on the same entity) more than 7 times in an hour, the 8th instance will fail with the below error.
"The error is triggered because, by default, CRM only allows for up to eight nested child workflows. When you attempt to run more, CRM will recognize it as an infinite loop and throw error message."
CRM has a limit for this depth. This can seen in MSCRM_Config database by executing the following query.

       COLUMNNAME = 'MessageProcessorMaximumDepth'

If we have really strong requirement that workflow should be called more than 8 times then we can update the value in the Database using the following update query.
WHERE COLUMNNAME = 'MessageProcessorMaximumDepth'

After updating, make sure you reset IIS so that new value will be considered by CRM. 

Note: This is unsupported, it may cause issue when you upgrade the CRM system to newer versions.
Hope this helps.
Happy CRM'ing


IsRegularActivity in CRM 2011/2013/2015

There are lots of activity types which don't look like regular activities, such as
Case Resolution
Bulk Operation
Opportunity Close

Quote Close
CRM creates activities when a Case/Opportunity/Quote is closed.
Go to Advanced Find and check the below.
The field IsRegularActivity on the Activity Pointer entity is set to no for CRM created Activities.

To know more about Activities check the below post

Activity Pointer and Activity Type Code in CRM 2011/2013/2015

Hope this helps.
Happy CRM'ing


Activity Pointer and Activity Type Code in CRM 2011/2013/2015

CRM has lots of different activities

1) Phone Call
2) Task
3) Letter
4) Email
5) Appointment
6) Fax
7) Custom Activities

In CRM, all the activities are saved in ActivityPointer table. This way, we can retrieve all activities with one request instead of multiple transactions.
Whenever you create an activity record in Microsoft Dynamics CRM, a corresponding activity pointer record is created. This implies that the activity record and the corresponding activity pointer record have the same value for the ActivityId attribute. For example, if you create an Email record, the attribute values of Email.ActivityId and the corresponding ActivityPointer.ActivityId will be the same.
We can differentiate the activities by Activity Type Code.

Case Resolution
Opportunity Close
Order Close
Phone Call
Quote Close
Service Activity
Recurring Appointment
Campaign Response
Campaign Activity
Bulk Operation

Hope this helps.
Happy CRM'ing

Thursday, 12 November 2015

Retrieve Product Properties using JavaScript in CRM 2015


Today we got a requirement to show Product Properties related to Opportunity Product in a HTML Webresource.

Here is the JavaScript code to read Product Properties.

  function getProperties() {
            var jsonResult = null;
            var ODATA_ENDPOINT = "/XRMServices/2011/OrganizationData.svc";
            var retrieveRecordsReq = new XMLHttpRequest();
            var oDataPath = "";
            var entityName = "DynamicPropertyInstance";
            var entityNameField = "*";
            oDataPath = Xrm.Page.context.getClientUrl() + ODATA_ENDPOINT + "/" + entityName + "Set?$select=*&$filter=RegardingObjectId/Id eq guid'" + vOpportunityProductId + "'";
  'GET', oDataPath, false);
            retrieveRecordsReq.setRequestHeader("Accept", "application/json");
            retrieveRecordsReq.setRequestHeader("Content-Type", "application/json; charset=utf-8")
            var retrievedData = JSON.parse(retrieveRecordsReq.responseText).d;
            if (retrievedData != null && retrievedData != undefined && retrievedData.results != null) {
                jsonResult = retrievedData.results;
             return jsonResult;
Hope this helps.


Happy CRM'ing

Wednesday, 11 November 2015

The column heading cannot be empty in CRM 2013/2015


Today I received the below error when I was importing some records to CRM using OOB import.

"The column heading cannot be empty".

Here are the steps to resolve.

1) Open the CSV file in notepad.
2) Check for a comma at the end of each row.
3) To make the things much easier, close the Notepad and open the same in Microsoft Excel.
4) Remove the blank column by selecting and deleting.
5) Save the file.
6) Open the file in Notepad again and check to make sure the comma at the end of each row has removed.
7) Import the file. This time, you won't see any error.

Hope this helps.

Happy CRM'ing

How to get the records count per table from SQL Server Database?


I have started working on Data Migration work. So, started knowing more on SQL Server, Tables, Database Sizes and etc..

Today, I found the way to know the Records count per table and size of each table in the Database.
Here are the steps to follow for getting the details.

1) Logon to SQL Server Management Studio
2) Right-click on the database which you want to know the details.
3) Select Reports -> Standard Reports -> Disk Usage by Table.

4) A report will be loaded in a new tab. This might take a couple of seconds depending on the size of the database.
5) You can export the report to Excel, PDF and Word and perform your analysis on it.
Note : This procedure can be applied for any database. As CRM Database is my favorite, I have taken that as a sample.

Hope this helps.

Happy Querying.


How to check the database size in SQL Server?

Today, I got know the size of the database. But unfortunately I could not get the correct database size on the file system until I take the back up.
Select the database, right click and click on properties.
In the above image, the size shown 460.81 MB is sum of Data and Log files. It doesn't mean that real size of the database would be the same.
I have taken the back up of the database and on the file system the size mentioned was 262 MB.
Space Available 90.03 MB is the space that is still available to fill up. Once this space is utilized then SQL Server will allocates new Data space and Log space as per the growth rate set.
Use the following query to see the size of Log files and data files individually.
SELECT DB_NAME(database_id) AS DatabaseName,
Name AS Logical_Name,
Physical_Name, (size*8)/1024 SizeMB
FROM sys.master_files
WHERE DB_NAME(database_id) = 'DB_NAME'

351 + 109 = 460 MB.
Hope this helps.


Tuesday, 10 November 2015

Security Roles Assigned to User in CRM


Today I have been asked by one of our clients is there any way to find the security privileges that are assigned to some users in CRM Organization.

Yes, we can see. Dynamics CRM out of the box comes with a set of reports. You will find a report named "User Summary".

If you run the report, you will see table with User's information. I cannot show you the output of the report here. :)

Hope this helps.

Happy CRM'ing


Monday, 9 November 2015

Double Versus Decimal in C#

Double is useful for scientific computations (such as computing spatial coordinates). Decimal is useful for financial computations and values that are “man-made” rather than the result of real-world measurements. Here’s a summary of the differences.

Internal RepresentationBase 2 Base 10
Decimal Precision15-16 Significant Figures28-29 Significant figures
Range±(~10−324 to ~10308) ±(~10−28 to ~1028) 
Special Values+0, −0, +∞, −∞, and NaNNone 
SpeedNative to processor Non-native to processor
(about 10 times slower than double)

Most business applications should probably be using decimal rather than float or double. Our thumb rule should be manmade values such as currency are usually better represented with decimal floating point.
Hope this helps.
Happy Coding