protected override void Execute(CodeActivityContext context) { var wfContext = context.GetExtension <IWorkflowContext>(); var id = wfContext.PrimaryEntityId; var servicefactory = context.GetExtension <IOrganizationServiceFactory>(); var service = servicefactory.CreateOrganizationService(null); AgreementService agreementService = new AgreementService(service); IsFirst.Set(context, agreementService.IsAgreementHaveNoAnyInvoice(id)); IsAnyInvoiceWhithFactEqTrue.Set(context, agreementService.IsAgreementHaveAnyInvoiceWhithFactEqTrue(id)); IsAnyInvoiceWhithTypeEqManually.Set(context, agreementService.IsAgreementHaveAnyInvoiceWhithTypeEqManually(id)); }