Example #1
0
        protected override void ExecuteLogic()
        {
            var targetRef = (EntityReference)Context.InputParameters["Target"];

            if (targetRef.LogicalName == CustomJobLog.EntityLogicalName)
            {
                Log.Log("Processing Log deletion ...");
                var jobLog = new CustomJobLog
                {
                    Id = targetRef.Id
                };
                jobLog.LoadRelation(CustomJobLog.RelationNames.CustomJobFailedTargetsOfLogEntry, Service);
                var failures = jobLog.CustomJobFailedTargetsOfLogEntry;

                if (failures != null)
                {
                    Log.Log($"Found {failures.Length} failed job entries.");

                    foreach (var failure in failures)
                    {
                        Log.Log($"Deleting '{failure.Id}' ...");
                        Service.Delete(CustomJobFailedTarget.EntityLogicalName, failure.Id);
                        Log.Log($"Deleted '{failure.Id}'.");
                    }
                }
            }
        }