0

Can anybody give an example or ref link for how to add data or create a record with CalenderRules type attribute using c# in dynamics crm.

Information about CalenderRules type attribute is displayed in below link.but can't find actually how to add.

https://msdn.microsoft.com/en-in/library/dn817862.aspx#BKMK_Image

chhaya_patel
  • 171
  • 1
  • 2
  • 15

1 Answers1

2

From the article you have referenced.

There are no actual attributes that use the CalendarRulesType. When using the early binding style, the code generation tool will create the following two simulated attributes that are not present in the metadata. These attributes actually represent a view of the calendar rules records associated in a one-to-many relationship to the entity instance.

Just like any other relationship, you can use Associate or just use the early/late bound attributes and reference the entity collection:

Early/Late bound:

calendar.CalendarRules = new[]
{
   new CalendarRule()
   {
      Id = calendarRuleId
   }
};

Associate:

 organizationService.Associate(Calendar.EntityLogicalName, calendarId, new Relationship("calendar_calendar_rules"),
                new EntityReferenceCollection(new[]
                {
                    new EntityReference(CalendarRule.EntityLogicalName, calendarRuleId)
                }));
dynamicallyCRM
  • 2,980
  • 11
  • 16