Sunday, 15 November 2015

Allow only numbers in a text box

Hi,

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.

<HTML>
   <HEAD>
   <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;
       }
      //-->
   </SCRIPT>
   </HEAD>
   <BODY>
      <INPUT id="txtChar" onkeypress="return isNumberPressed(event)" type="text" name="txtChar">
   </BODY>
</HTML>
 
Hope this helps.

--
Happy Coding
Gopinath

Saturday, 14 November 2015

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

Hi,
 
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.

SELECT * FROM
       DEPLOYMENTPROPERTIES
WHERE
       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.
 
UPDATE DEPLOYMENTPROPERTIES
SET INTCOLUMN = <Number>
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

Gopinath 

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.
Results
 
The field IsRegularActivity on the Activity Pointer entity is set to no for CRM created Activities.
Results

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

Gopinath

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.

Value
Label
4201
Appointment
4202
Email
4204
Fax
4206
Case Resolution
4207
Letter
4208
Opportunity Close
4209
Order Close
4210
Phone Call
4211
Quote Close
4212
Task
4214
Service Activity
4251
Recurring Appointment
4401
Campaign Response
4402
Campaign Activity
4406
Bulk Operation

Hope this helps.
 
--
Happy CRM'ing
Gopinath

Thursday, 12 November 2015

Retrieve Product Properties using JavaScript in CRM 2015

Hi,

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 + "'";
            retrieveRecordsReq.open('GET', oDataPath, false);
            retrieveRecordsReq.setRequestHeader("Accept", "application/json");
            retrieveRecordsReq.setRequestHeader("Content-Type", "application/json; charset=utf-8")
            retrieveRecordsReq.send(null);
            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
Gopinath

Wednesday, 11 November 2015

The column heading cannot be empty in CRM 2013/2015

Hi,

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
Gopinath

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

Hi,

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.

Gopinath 

How to check the database size in SQL Server?

Hi,
 
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'

Output
351 + 109 = 460 MB.
 
Hope this helps.
 
--
Cheers

Gopinath 

Tuesday, 10 November 2015

Security Roles Assigned to User in CRM

Hi,

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

Gopinath

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.
  

CategoryDoubleDecimal
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
Gopinath