Anyone have any idea how to access a variable from a previous workflow activity, from another custom activity in C#?
I'm not sure the nomenclature of what you mean by a user defined action. I am creating a custom action & activity to make a call to a REST API. That REST call will return an ID in the response payload. I need to pass this value through the workflow to be accessed by the second action downstream.
So, in my actionAdapter.cs code, I define a variable:
c.Parameters[7] = new ActivityParameter();
c.Parameters[7].Name = Parameter_ObjectIdOutput;
c.Parameters[7].Variable = new NWWorkflowVariable();
Then, in the execute method of my Activity.cs, I run my code to access our service using the configuration info provided in the action (when placed in the workflow). This returns me the response payload, with my object ID. I push this to my action variable "ObjectIdOutput".
this.ObjectIdOutput = objectId; //where objectId is the value returned from my service.
ctx.Variables.Add("ObjectIdOutput", ctx.AddContextDataToString(ObjectIdOutput, true)); //this was added to try the next step below
In the second custom action/activity, I need to be able to grab this object ID so that I can run a status check, via the REST API for our service. I have not been able to find any example of grabbing this value. I've tried several things, including trying to grab it from:
string oID = ctx.Variables["ObjectIdOutput"].ToString();
This obviously isn't right as I get an error when I place both in a workflow and execute it. The first action runs successfully, but the second fails when it cannot access that variable.