Пример #1
0
        protected override void Execute(CodeActivityContext executionContext)
        {
            var context        = executionContext.GetExtension <IWorkflowContext>();
            var serviceFactory = executionContext.GetExtension <IOrganizationServiceFactory>();
            var service        = serviceFactory.CreateOrganizationService(context.UserId);

            var textPar = TextParam.Get <string>(executionContext);
            var intPar  = IntParam.Get <int>(executionContext);
            var email   = EmailParam.Get <string>(executionContext);

            Entity updatedEntity = new Entity(context.PrimaryEntityName);

            updatedEntity.Id            = context.PrimaryEntityId;
            updatedEntity["new_textin"] = textPar;
            updatedEntity["new_number"] = intPar;
            {
                OutParam.Set(executionContext, email);
            }
            service.Update(updatedEntity);
        }
Пример #2
0
        protected override void Execute(CodeActivityContext executionContext)
        {
            var context        = executionContext.GetExtension <IWorkflowContext>();
            var serviceFactory = executionContext.GetExtension <IOrganizationServiceFactory>();
            var service        = serviceFactory.CreateOrganizationService(context.UserId);

            string          textPar = TextParam.Get <string>(executionContext);
            int             intPar  = IntParam.Get <int>(executionContext);
            EntityReference company = Account.Get <EntityReference>(executionContext);

            Entity updatedEntity = new Entity(context.PrimaryEntityName)
            {
                Id = context.PrimaryEntityId
            };

            updatedEntity["new_text"] = textPar;
            updatedEntity["new_noun"] = intPar;

            if (company == null)
            {
                OutParam.Set(executionContext, "Record doesn't have account");
            }
            else
            {
                Entity account = service.Retrieve(company.LogicalName, company.Id, new ColumnSet("emailaddress1"));
                if (account.Attributes.ContainsKey("emailaddress1"))
                {
                    OutParam.Set(executionContext, account.GetAttributeValue <string>("emailaddress1"));
                }
                else
                {
                    OutParam.Set(executionContext, "Record's account doesn't have Email");
                }
            }

            service.Update(updatedEntity);
        }