Mam następujący problem:Usuń lub Usuń Kalendarz Rule „Time Off Rule” poprzez wtyczki lub prostych aplikacji konsoli w C# dla CRM 2015
muszę usunąć lub usunąć „OFF TIME Rule” z Regulaminem kalendarzowego szczególny kalendarz należący do "Sprzętu". Należy to zrobić, aby sprzęt był dostępny do planowania w kalendarzu usług.
Jakoś nie mogę zrozumieć, jak to zrobić.
Jestem w stanie odzyskać obiekt reguły kalendarza, który musi zostać usunięty, ale wymyka się kolejny krok.
Proszę być na tyle uprzejmy, aby dać mi znać:
Można to zrobić za pośrednictwem C# (SDK)
dowolnego zasobu sieciowego lub części kodu, który robi coś podobnego.
Poniższy kod daje mi błąd
Przedmiotem próbowałeś usunąć związana jest z innym obiektem i nie mogą być usunięte.
//equip is of Equipment type and is already initialized
CrmEarlyBound.Calendar cal = (CrmEarlyBound.Calendar)svc.Retrieve("calendar", equip.CalendarId.Id, new ColumnSet(true));
Console.WriteLine("Got the user calendar");
List<CalendarRule> calendarRules = cal.CalendarRules.ToList();
Console.WriteLine("Got the calendar rules " + cal.CalendarRules.ToList().Count);
foreach (CalendarRule cr in cal.CalendarRules)
{
if (cr.Description == "Time Off Rule" && cr.StartTime.Value>=DateTime.Now)
{
Console.WriteLine(cr.StartTime);
Calendar calI = (Calendar)svc.Retrieve(cr.InnerCalendarId.LogicalName, cr.InnerCalendarId.Id, new ColumnSet(true));
//svc.Delete(cr.InnerCalendarId.LogicalName, cr.InnerCalendarId.Id);
}
}