Показать сообщение отдельно
Старый 11.12.2018, 21:14   #37  
Ion is offline
Ion
Участник
 
332 / 16 (1) ++
Регистрация: 19.12.2012
Кстати и я столкнулся с удаленными контактами в appointments. Такой солюшен по их воссозданию ок?

X++:
            Guid entityId = Guid.Parse("93c31bd0-848b-e811-8118-00155df17501");
            string entityLogicalName = "contact";

            // Retrieve the audit records for entity.
            RetrieveRecordChangeHistoryRequest changeRequest = new RetrieveRecordChangeHistoryRequest();
            changeRequest.Target = new EntityReference(entityLogicalName, entityId);

            RetrieveRecordChangeHistoryResponse changeResponse =
               (RetrieveRecordChangeHistoryResponse)connection.Execute(changeRequest);

            AuditDetailCollection details = changeResponse.AuditDetailCollection;

            for (int count = 0; count < details.Count; count++)
            {
                if (typeof(AttributeAuditDetail).Name == details[count].GetType().Name)
                {
                    AttributeAuditDetail detail = details[count] as AttributeAuditDetail;
       
                    if (detail.NewValue == null && detail.OldValue != null)
                    {
                        Entity entity = detail.OldValue;
                        connection.Create(entity);
                        break;
                    }
                }
            }
За это сообщение автора поблагодарили: a33ik (1).