Пример #1
0
        protected void OnItemSaving(object sender, EntityFormSavingEventArgs e)
        {
            XrmConnection _conn   = new XrmConnection();
            var           service = new XrmServiceContext(_conn);

            Guid   entityId    = EntityForm1.EntitySourceDefinition.ID;
            string logicalName = EntityForm1.EntitySourceDefinition.LogicalName;

            e.Cancel = service.HasDuplicate(logicalName, e.Values, entityId);

            if (e.Cancel)
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "CallMyFunction", "DupeDetectedNotification();", true);
            }
        }