date and time field behavior in MS CRM

For CRM versions earlier than CRM Online 2015 Update 1 and CRM 2016 (on-premises), you cannot define the behavior of the date and time values. By default, the date and time values are stored as  UserLocal.

But in latest version,  behavior of date and time field is classified as 3 types.




UserLocal:
·         This behavior always stores the date and time in UTC format. While retrieving, it will returns date and time in UTC format.
·         When user trying to update date and time, if user enters date in UTC, system will update the value as it is or else it will convert entered date and time into UTC format then stores.
·         This behavior is used for system attributes like CreatedOn and ModifiedOn, and cannot be changed. You should use this behavior for custom attributes where you want to store date and time values with the time zone information
DateOnly:
·         This behavior will stores date only and time will be always stores as 12:00AM (00:00:00).
·         While retrieving the value also, time will always carries as 12:00AM.
·         This behavior should be used for custom attributes that store birthdays and anniversaries, where the time information is not required

TimeZoneIndependent:
·         Stores the date and time in system regardless of user time zone.
·         While updating the date and time also, it will stores date and time what user enters as it is.


·         This behavior should be used for attributes that store information such as check in and check out time for hotel

If you do not specify the behavior while creating a date and time attribute, the attribute is created with the UserLocal behavior by default



You may like below posts

Improving MS CRM Performance

Performance Center in MS CRM 2013

Upsert in MSCRM

Locking mechanism in MS CRM

Ticker Symbol Field in MS CRM

Themes in MS CRM

Enable Tracing in MS CRM

Calculated Field in Dynamics CRM 2015

IME Mode in MS CRM

Date and Time field in MS CRM

Date and Time fields generally are meant to store date and time. Did you ever tested, what is the max early date you can give in that field?


If not, try with 12/31/1899 if you are using MS CRM 2015 on premises with update 1 or earlier version. And, you will get an error as “The specified date format is invalid or the date is out of valid range”. Because maximum early date you can give is 1/1/1900 or later


Now, MS CRM easing this restriction in MS CRM 2015 online with update 1 or 2016 on-premises. In these versions, you can give date as early as “1/1/1753 12:00 AM



You may like below posts

Improving MS CRM Performance

Performance Center in MS CRM 2013

date and time field behavior in MS CRM

Upsert in MSCRM

Locking mechanism in MS CRM

Ticker Symbol Field in MS CRM

Themes in MS CRM

Enable Tracing in MS CRM

Calculated Field in Dynamics CRM 2015

IME Mode in MS CRM

Language Setting in MS CRM

Now a days, so many applications providing the feature to view their application in user preferred language or region language. MS CRM also provide this feature. Below are the steps to follow to enable the languages.






MS CRM -> Settings -> Administration -> Languages


Upon click on languages, one screen(as shown below) will show you the supporting languages by MS CRM. By selecting one of the required language and applying, it will the selected language to user’s preference list.





Now, in terms of user, how he or she can change the language?


Below are the steps users to follow to change his language.

Settings (It is users settings as shown in below screen) - > Options (Click on options)-> Languages -> User Interface Language.











Upsert in MSCRM

If we want to update a record in any entity, we should require GUID. If we know the GUID, we can do it easily, if not, we should retrieve the GUID of that record first, then we can update the record. Here, two database calls (Retrieve and Update) we are making which impacts performance of an application.


In these scenarios, Upsert will be very useful. Upsert request will check in database whether record exists in database, if exists it will update the record or else it will create the record.






So, how do we know that whether Upsert create or update record in each call?


This information we can get from UpsertResponse which contains a Boolean property RecordCreated. If RecordCreated contains “true” it indicates Upsert created the record else updated the record.


Sample Code:

               Entity testEntity = new Entity("new_test");
                testEntity["new_test1"] = "test1";
                testEntity["new_test2"] = "test2";
                testEntity["new_test3"] = "test3";

                UpsertRequest request = new UpsertRequest()
                {
                    Target = testEntity
                };
                try
                {
                    UpsertResponse response = (UpsertResponse)_serviceProxy.Execute(request);
                }
                catch (Exception ex)
                {
                  }


Note: For Microsoft Dynamics CRM Online organizations, this feature is available only if your organization has updated to Dynamics CRM Online 2015 Update 1. This feature is not available for Dynamics CRM (on-premises).




You may like below posts

Improving MS CRM Performance

Performance Center in MS CRM 2013

date and time field behavior in MS CRM

Locking mechanism in MS CRM

Ticker Symbol Field in MS CRM

Themes in MS CRM

Enable Tracing in MS CRM

Calculated Field in Dynamics CRM 2015

IME Mode in MS CRM

Alternate Keys in MS CRM

In MS CRM, primary key place very important role in uniquely identifying the records in an entity. Alternatively, MS CRM introducing new concept called “Alternative Keys” to identify the records.


So, we will see more on how to create and use alternative keys.
In each entity customizations we have a link called Keys as shown below.

Alternative Key
















On click on New button, below screen will appears.
We need to give alternative key name in Display name and have to select one or more attributes from available attributes.


Alternative Key - Attributes

















You should be aware of the following constraints when creating alternative keys.

  • Only, Decimal number, Whole number or Single line of text can be an alternative key.
  • As key should be supported by platform, it will validate the key before it is creating. So the constraint is 900 bytes per key and 16 columns per key. If the key size doesn’t meet the constraint, an error message will be pop up while creating the key
  • There can be a maximum of 5 alternate key definitions for an entity in a CRM instance.


Workflow throws "Invalid Argument" on Set Properties in MS CRM

We may have a requirement of, on create of a particular record, we need to update another record... For these kind of requirements, we generally use out of the box workflows.


When we have created workflow, and click on "Set Properties", sometimes it will through "Invalid Argument" exception. This exception will not give any other information other than "Invalid Exception".





To get more information on exception we need to enable the tracing. To more on how to enable tracing click this link.

If you read the trace file carefully, you will find the reason of this issue as “Wrong type of attribute UI properties passed to the attribute "new_fieldname"”. So, we need to remove this field from form, Save and Publish then try to set properties. If there are no other fields which causing this issue, form will open or else you will get "Invalid Argument" exception again, so we need to iterate this process till we remove all issue causing fields.


Locking mechanism in MS CRM

When CRM is interacting with SQL server what exactly happening in terms of locking at database?..., Here I am trying to articulate the locking mechanism at my best.

When CRM trying to interface with SQL server, SQL server determines which locks it should be apply against a record or table.




  1. If CRM is trying to read a record, SQL server applies Read lock on that record.
  2. If CRM is trying to read multiple of records, SQL server decides whether it should apply Read lock on entire table or respective records
  3. If CRM is creating a record, SQL server applies Write lock on that record.
  4. If CRM is updating a record, CRM will applies write lock on that record.
  5. There may be scenarios SQL server does not apply any locks.
CRM executes all the request under a single transaction each time it is hitting database, SQL server holds the lock until transaction completed. Once the transaction is completed SQL server will release the lock on that record or transaction.

Below scenario explains how the system reacts when multiple of users updating the same record at same time.

























When first transaction gets lock and started it execution, second transaction will be blocked until it gets lock on that record i.e. blocked until first transaction complete.


Sometimes blocking may cause timeout issue when the multiple request executes parallel. The first request can easily lock the record and complete it requests, but the second request should wait until the first request release its lock. Similarly, thirst request should also wait until first and second requests to complete. The more requests there are, the longer blocking will occur. If there are enough requests, and each request takes long enough, this can push the later requests to the point that they time out, even though individually they may complete correctly.




You may like below posts

Improving MS CRM Performance

Performance Center in MS CRM 2013

date and time field behavior in MS CRM

Upsert in MSCRM

Ticker Symbol Field in MS CRM

Themes in MS CRM

Enable Tracing in MS CRM

Calculated Field in Dynamics CRM 2015


IME Mode in MS CRM

Featured Post

Improving MS CRM Performance

Performance on MS CRM is always a crucial thing and we may follow different ways to achieve the performance thing. Below is the one more a...