protected override void ExecuteCrmWorkFlowActivity(CodeActivityContext context, LocalWorkflowContext localContext)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }
            if (localContext == null)
            {
                throw new ArgumentNullException(nameof(localContext));
            }

            EntityReference noteToUpdate = NoteToUpdate.Get(context);

            if (noteToUpdate == null)
            {
                throw new ArgumentNullException("Note cannot be null");
            }

            string newText = NewText.Get(context);

            Entity note = new Entity("annotation")
            {
                Id           = noteToUpdate.Id,
                ["notetext"] = newText
            };

            localContext.OrganizationService.Update(note);

            UpdatedText.Set(context, newText);
        }
Пример #2
0
        protected override void Execute(CodeActivityContext executionContext)
        {
            ITracingService tracer = executionContext.GetExtension<ITracingService>();
            IWorkflowContext context = executionContext.GetExtension<IWorkflowContext>();
            IOrganizationServiceFactory serviceFactory = executionContext.GetExtension<IOrganizationServiceFactory>();
            IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);

            try
            {
                EntityReference noteToUpdate = NoteToUpdate.Get(executionContext);
                string newTitle = NewTitle.Get(executionContext);

                Entity note = new Entity("annotation");
                note.Id = noteToUpdate.Id;
                note["subject"] = newTitle;
                service.Update(note);

                UpdatedTitle.Set(executionContext, newTitle);
            }
            catch (Exception e)
            {
                throw new InvalidPluginExecutionException(e.Message);
            }
        }