Debunking: KingswaySoft Dynamics CRM Source- Output Timezone

Hi! I'm back after so a long hiatus (probably I'll write the reason for this later 🤣). As [lazy] Developers, we're most likely to interact with a "wrapper" (can be components, services, etc) that hides all the complexity needed. But, I believe at some point, we will be facing some issues which force us to dig deeper to understand better the "wrapper" that we are using. For instance, regarding KingswaySoft Dynamics CRM Source - Output Timezone. I encountered the error SQL Timeout, which led me to analyze more deeply how the component works. With the help of Fiddler Classic, here is the summary of my learning! Enjoy!

Fiddler Setup

The Fiddlersetup is pretty easy. I just need to enable the filter of my Dynamics CRM URL:

Enable Filter for your Dynamics CRM instance

Enable Filter for your Dynamics CRM instance

You only need to start your Fiddler > Go to Filters > Request Headers > Tick the "Show only if URL contains" > in the textbox, put your CRM URL.

Dynamics CRM Source - Output Timezone: UTC (Default)

Next, I created a simple package that retrieves the FullName and CreatedOn of Contacts:

Dynamics CRM Source - Output Timezone: UTC (Default)

Dynamics CRM Source - Output Timezone: UTC (Default)

After I executed the Package, here are the important steps (I skipped the part that was not necessary, such as Authentication, Retrieving Version, etc) from the Fiddler:

RetrieveMultipleRequest

RetrieveMultipleRequest

As you can see in the above screenshot, it will directly execute RetrieveMultipleRequest(from FetchXML), and the Dataverse will return the RetrieveMultipleResponse!

Dynamics CRM Source - Output Timezone: Adjust to timezone of Connection User

Here is how to set the Output Timezone to "Adjust to timezone of Connection User":

Dynamics CRM Source - Output Timezone: Adjust to timezone of Connection User

Dynamics CRM Source - Output Timezone: Adjust to timezone of Connection User

Before retrieving the data, the system will be execute the following:

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Header><UserType xmlns="http://schemas.microsoft.com/xrm/2011/Contracts">CrmUser</UserType><SdkClientVersion xmlns="http://schemas.microsoft.com/xrm/2011/Contracts">9.1.0.0</SdkClientVersion></s:Header><s:Body><RetrieveMultiple xmlns="http://schemas.microsoft.com/xrm/2011/Contracts/Services"><query i:type="a:FetchExpression" xmlns:a="http://schemas.microsoft.com/xrm/2011/Contracts" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><a:Query>&lt;fetch mapping='logical'&gt;
  &lt;entity name='timezonerule'&gt;
    &lt;attribute name='bias' /&gt;
    &lt;attribute name='daylightbias' /&gt;
    &lt;attribute name='daylightyear' /&gt;
    &lt;attribute name='daylightmonth' /&gt;
    &lt;attribute name='daylightday' /&gt;
    &lt;attribute name='daylighthour' /&gt;
    &lt;attribute name='daylightminute' /&gt;
    &lt;attribute name='daylightsecond' /&gt;
    &lt;attribute name='daylightdayofweek' /&gt;
    &lt;attribute name='standardbias' /&gt;
    &lt;attribute name='standardyear' /&gt;
    &lt;attribute name='standardmonth' /&gt;
    &lt;attribute name='standardday' /&gt;
    &lt;attribute name='standardhour' /&gt;
    &lt;attribute name='standardminute' /&gt;
    &lt;attribute name='standardsecond' /&gt;
    &lt;attribute name='standarddayofweek' /&gt;
    &lt;attribute name='effectivedatetime' /&gt;
    &lt;link-entity name='timezonedefinition' to='timezonedefinitionid' from='timezonedefinitionid' alias='d' link-type='inner'&gt;
      &lt;link-entity name='usersettings' to='timezonecode' from='timezonecode' alias='us' link-type='inner'&gt;
        &lt;filter&gt;
          &lt;condition attribute='systemuserid' operator='eq-userid' /&gt;
        &lt;/filter&gt;
      &lt;/link-entity&gt;
    &lt;/link-entity&gt;
    &lt;order attribute='timezoneruleversionnumber' descending='true' /&gt;
    &lt;order attribute='effectivedatetime' descending='true' /&gt;
  &lt;/entity&gt;
&lt;/fetch&gt;</a:Query></query></RetrieveMultiple></s:Body></s:Envelope>

Last, it will execute the query retrieval and in KingswaySoft will process based on the User Timezone (The AppUser that I'm using is set as MYT - UTC+8):

CreatedOn set as MYT on the result

CreatedOn is set as MYT on the result

Dynamics CRM Source - Output Timezone: Adjust to timezone of Impersonate User

Last, the impersonated user. We need to select first the user that we want, and set the Output Timezone to "Adjust to timezone of Impersonate User":

Dynamics CRM Source - Output Timezone: Adjust to timezone of Impersonate User

Dynamics CRM Source - Output Timezone: Adjust to timezone of Impersonate User

When we execute the package, it will run the following query:

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Header><CallerId xmlns="http://schemas.microsoft.com/xrm/2011/Contracts">f9e7905c-cf7a-ee11-8179-002248201668</CallerId><UserType xmlns="http://schemas.microsoft.com/xrm/2011/Contracts">CrmUser</UserType><SdkClientVersion xmlns="http://schemas.microsoft.com/xrm/2011/Contracts">9.1.0.0</SdkClientVersion></s:Header><s:Body><RetrieveMultiple xmlns="http://schemas.microsoft.com/xrm/2011/Contracts/Services"><query i:type="a:FetchExpression" xmlns:a="http://schemas.microsoft.com/xrm/2011/Contracts" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><a:Query>&lt;fetch mapping='logical'&gt;
  &lt;entity name='timezonerule'&gt;
    &lt;attribute name='bias' /&gt;
    &lt;attribute name='daylightbias' /&gt;
    &lt;attribute name='daylightyear' /&gt;
    &lt;attribute name='daylightmonth' /&gt;
    &lt;attribute name='daylightday' /&gt;
    &lt;attribute name='daylighthour' /&gt;
    &lt;attribute name='daylightminute' /&gt;
    &lt;attribute name='daylightsecond' /&gt;
    &lt;attribute name='daylightdayofweek' /&gt;
    &lt;attribute name='standardbias' /&gt;
    &lt;attribute name='standardyear' /&gt;
    &lt;attribute name='standardmonth' /&gt;
    &lt;attribute name='standardday' /&gt;
    &lt;attribute name='standardhour' /&gt;
    &lt;attribute name='standardminute' /&gt;
    &lt;attribute name='standardsecond' /&gt;
    &lt;attribute name='standarddayofweek' /&gt;
    &lt;attribute name='effectivedatetime' /&gt;
    &lt;link-entity name='timezonedefinition' to='timezonedefinitionid' from='timezonedefinitionid' alias='d' link-type='inner'&gt;
      &lt;link-entity name='usersettings' to='timezonecode' from='timezonecode' alias='us' link-type='inner'&gt;
        &lt;filter&gt;
          &lt;condition attribute='systemuserid' operator='eq' value='f9e7905c-cf7a-ee11-8179-002248201668' /&gt;
        &lt;/filter&gt;
      &lt;/link-entity&gt;
    &lt;/link-entity&gt;
    &lt;order attribute='timezoneruleversionnumber' descending='true' /&gt;
    &lt;order attribute='effectivedatetime' descending='true' /&gt;
  &lt;/entity&gt;
&lt;/fetch&gt;</a:Query></query></RetrieveMultiple></s:Body></s:Envelope>

It will retrieve the ***timezonerule***table based on the Impersonate User that we have selected.

Then, it will be querying the data, and KingswaySoft will process the data and add the time based on the Impersonated User (in this case, I set the impersonated user to UTC+7):

CreatedOn is set as IWST (UTC+7) on the result

Summary

In short, here is the flowchart on how KingswaySoft processes the Output Timezone:

Summary on how KingswaySoft Dynamics CRM Source - Output Timezone works

Summary on how KingswaySoft Dynamics CRM Source - Output Timezone works

Happy CRM-ing! 😎

Leave a comment

Your comment is sent privately to the author and isn't published on the site.