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);
        }
        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          newText      = NewText.Get(executionContext);

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

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