예제 #1
0
        protected override void Execute(CodeActivityContext executionContext)
        {
            //Create the tracing service
            ITracingService tracingService = executionContext.GetExtension <ITracingService>();

            //Create the context
            IWorkflowContext            context        = executionContext.GetExtension <IWorkflowContext>();
            IOrganizationServiceFactory serviceFactory = executionContext.GetExtension <IOrganizationServiceFactory>();
            IOrganizationService        service        = serviceFactory.CreateOrganizationService(context.UserId);

            tracingService.Trace("Resolving Account from Context");

            Account entity = new Account();

            entity.Id = ((EntityReference)AccountReference.Get <EntityReference>(executionContext)).Id;

            tracingService.Trace("Account resolved with Id {0}", entity.Id.ToString());

            tracingService.Trace("Create a note for the account");
            Annotation newNote = new Annotation();

            newNote.Subject  = NoteSubject.Get <string>(executionContext);
            newNote.NoteText = NoteBody.Get <string>(executionContext);
            newNote.ObjectId = entity.ToEntityReference();

            Guid noteId = service.Create(newNote);

            tracingService.Trace("Note has been created");

            NoteReference.Set(executionContext, new EntityReference(Annotation.EntityLogicalName, noteId));
        }
예제 #2
0
        protected override void Execute(CodeActivityContext executionContext)
        {
            IWorkflowContext            context             = executionContext.GetExtension <IWorkflowContext>();
            IOrganizationServiceFactory serviceFactory      = executionContext.GetExtension <IOrganizationServiceFactory>();
            IOrganizationService        organizationService = serviceFactory.CreateOrganizationService(context.UserId);

            var id      = AccountReference.Get(executionContext).Id;
            var account = organizationService.Retrieve("account", id, new ColumnSet(new[] { "name" }));

            OutputAccount.Set(executionContext, account);
            // TODO-osy: try if this works at all
            OutputAccountReference.Set(executionContext, new EntityReference("account", new KeyAttributeCollection()
            {
                new KeyValuePair <string, object>("Id", id), new KeyValuePair <string, object>("Name", account.LogicalName)
            }));
        }