public override void Executed(WorkflowData data) { try { EntityReference agreementRef = AgreementReference.Get(data.Context); Entities.new_agreement entity = data.Target.ToEntity <Entities.new_agreement>(); AgreementService service = new AgreementService(data.OrganizationService); service.DeleteRelatedInvoicesWithAutoType(agreementRef); service.CreatePaymentSchedule(entity); service.UpdateAgreementScheduleDate(entity); } catch (Exception ex) { data.TracingService.Trace(ex.ToString()); throw new InvalidWorkflowException(ex.Message); } }