web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Unanswered

Simple custom activity plugin that retrieves and displays a value won't work

(0) ShareShare
ReportReport
Posted on by
Hi. Ignore the name of this plugin because at this point I'm only trying to achieve something very simple from which then I could build something more complex. But even the simplest thing will not work. I'm still fairly new to plugins and custom activities so if anyone can pinpoint what I'm doing wrong, I'd be really grateful. First, here is the code of this custom activity, and at this point I'm only trying to retrieve the contactid, convert it to string and then be able to display it in some string field out there after I run a workflow on demand:
 
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Query;
using Microsoft.Xrm.Sdk.Workflow;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Activities;
namespace WheatonPluginDelta.Activities
{
    public class RetrieveRaceOfPerson : CodeActivity
    {
        //Required input:
        [RequiredArgument]
        [Input(/PersonReference/)]
        [ReferenceTarget(/contact/)]
        public InArgument<EntityReference> PersonRef { get; set; }
 
        [Output(/StringTest2/)]
        public OutArgument<string> StringTest2 { get; set; }
        protected override void Execute(CodeActivityContext executionContext)
        {
            ITracingService tracingService = executionContext.GetExtension<ITracingService>();
            IWorkflowContext workflowContext = executionContext.GetExtension<IWorkflowContext>();
            IOrganizationServiceFactory serviceFactory = executionContext.GetExtension<IOrganizationServiceFactory>();
            IOrganizationService orgService = serviceFactory.CreateOrganizationService(workflowContext.UserId);

            EntityReference personRef = PersonRef.Get(executionContext);
            var contact = orgService.Retrieve(/contact/, personRef.Id, new ColumnSet(/contactid/));
            StringTest2.Set(executionContext, contact[/contactid/].ToString());

        }
    }
}
 
Here is the setup of this custom activity where it asks for the input for the workflow:
 
//
 
And then I set up the output to be StringTest2 from the custom activity to go to any other field that is of type string. Then I run the workflow on demand, and it doesn't work! Field does not get populated with the person's contactid.
 
Can someone please enlighten me on what I'm doing wrong on something so simple?
 
Thanks.
I have the same question (0)

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Andrés Arias – Community Spotlight

We are honored to recognize Andrés Arias as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Daniyal Khaleel Profile Picture

Daniyal Khaleel 143

#2
DAnny3211 Profile Picture

DAnny3211 134

#3
Abhilash Warrier Profile Picture

Abhilash Warrier 70 Super User 2025 Season 2

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans