0
votes
  1. I have created Holiday Schedule Record in OrgA. This Record is created under Entity "calendar".
  2. I could move this Record using XrmToolBox Data Transport Tool.
  3. Inside (Related) to Holiday Schedule record there are many Rules i.e may Records. They are from Entity "calendar Rule".
  4. I wish to import these "Calendar Rule" Records from OrgA to OrgB.

Additional Information:

When I tried to retrieve "Calendar Rule" using fetchxml Builder it gave me Error stating

Retrieve multiple is not supported

Using CRMRESTBuilder "Calendar Rule" entity is not available. Using Data Transporter it did not transported records and threw error as

"Retrieve multiple is not supported"

Below Link is useful to understand Calendar and all it's related Entities. https://www.inogic.com/blog/2014/08/calendars-and-expand-calendar-request-in-crm-2013-sp-1/

1

1 Answers

1
votes

The CalendarRule entity can be retrieved using XrmToolbox's FetchXml Tester, which indicates that it supports ExecuteFetchRequest but not RetrieveMultiple.

I wrote an article on CRM Tip of the Day about entities that exhibit this behavior: https://crmtipoftheday.com/796/long-live-executefetchrequest/

Query:

<fetch>
    <entity name="calendarrule" />
</fetch>

Response (first record):

<result>
    <groupdesignator>
        FC5769FC-4DE9-445d-8F4E-6E9869E60857
    </groupdesignator>
    <rank formattedvalue="2" >
        2
    </rank>
    <createdon date="4/11/2019" time="8:55 PM" >
        2019-04-11T20:55:16-04:00
    </createdon>
    <starttime date="12/31/1999" time="7:00 PM" >
        1999-12-31T19:00:00-05:00
    </starttime>
    <organizationid>
        {3906F615-4DCD-422D-A3E3-F79134C7CCEF}
    </organizationid>
    <isselected name="Yes" >
        1
    </isselected>
    <duration formattedvalue="1,440" >
        1440
    </duration>
    <innercalendarid type="4003" >
        {7177F09C-BD5C-E911-A817-000D3A37FFD3}
    </innercalendarid>
    <isvaried name="No" >
        0
    </isvaried>
    <modifiedon date="4/11/2019" time="8:55 PM" >
        2019-04-11T20:55:16-04:00
    </modifiedon>
    <createdby name="--- ---" dsc="" yomi="--- ---" type="8" >
        {EE10412E-68E7-471D-A10C-D28FCE63B6F3}
    </createdby>
    <calendarruleid>
        {7277F09C-BD5C-E911-A817-000D3A37FFD3}
    </calendarruleid>
    <timezonecode formattedvalue="92" >
        92
    </timezonecode>
    <pattern>
        FREQ=WEEKLY;INTERVAL=1;BYDAY=MO,TU,WE,TH,FR
    </pattern>
    <description>
        Weekly Single Rule
    </description>
    <modifiedby name="--- ---" dsc="" yomi="--- ---" type="8" >
        {EE10412E-68E7-471D-A10C-D28FCE63B6F3}
    </modifiedby>
    <calendarid type="4003" >
        {7077F09C-BD5C-E911-A817-000D3A37FFD3}
    </calendarid>
    <effectiveintervalend date="12/30/9999" time="6:59 PM" >
        9999-12-30T18:59:59-05:00
    </effectiveintervalend>
    <businessunitid>
        {79263477-AA5C-E911-A817-000D3A37FFD3}
    </businessunitid>
</result>

Here's some sample C# code (not tested in current form):

using Microsoft.Crm.Sdk.Messages;
using Microsoft.Xrm.Sdk.Query;
using Microsoft.Xrm.Tooling.Connector;

public void Run()
{
    var connectionString = "Url=https://foobar.crm.dynamics.com; [email protected]; Password=myPass; AuthType=Office365";     
    var crmSvcClient = new CrmServiceClient(connectionString);

    var fetch = @"<fetch mapping='logical'>
                    <entity name='calendarrule' />                                  
                  </fetch>";

    var executeFetchReq = new ExecuteFetchRequest 
    { 
        FetchXml = fetch 
    };

    //Works
    var crmSvcExecuteFetchResponse = crmSvcClient.Execute(executeFetchReq);
    //Doesn't work
    var crmSvcRetrieveMultipleResponse = crmSvcClient.RetrieveMultiple(new FetchExpression(fetch));
}