cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Nintex Newbie

How can I read nintext variable from C# code?

Dears,

I want to know if I can read nintext variable from C# code?

Labels: (2)
0 Kudos
Reply
10 Replies
Highlighted
Automation Master
Automation Master

Re: How can I read nintext variable from C# code?

Mohammad, I'm not sure the context from which you would like to read the variable. There is a Workflow SDK The Nintex Workflow 2013 SDK is (initially) released!​ You can create custom actions within workflows using c#. Please provide more information on what you are trying to do so we can help.

Reply
Highlighted
Nintex Newbie

Re: How can I read nintext variable from C# code?

I declared variable in nintex workflow, I want to get the value of the variable in my code C#.

Reply
Highlighted
Automation Master
Automation Master

Re: How can I read nintext variable from C# code?

Sorry, I still have no context here. I don't see how a workflow will communicate with your code. Is your code a solution in SharePoint or is it hosted elsewhere? Does the code run from a dll in the server farm? How will the code get in context with the workflow since the workflow is stateless with the database and running in either the Application Pool or through the OWStimer through the SharePoint Foundation Workflow Timer? So the workflow can be in multiple places depending on several variables. Do you need to get the variable value while in flight or after it is complete?

The most simplest way you can do this is to have the workflow variable stored into a SharePoint list using the Set Field, Update Item, Update Multiple Items, or Create Item action. Then the value of the workflow variable will have a state and you can get that value using the server API or CSOM api to fetch the value, or even use PowerShell as you can uase c# code in PowerShell.

Please provide a little more guidance and I'm sure we can find a solution for you.

Reply
Highlighted
Not applicable

Re: How can I read nintext variable from C# code?

Hi Mohammad,

As far as I know the workflow variables are dynamic entities and are in existence only during the run time of the workflow. As Andrew mentioned above, the most easy way in which you can do this is by storing the value of this variable in list and then calling the stored value from the C# code.

0 Kudos
Reply
Highlighted
Automation Master
Automation Master

Re: How can I read nintext variable from C# code?

Let us know if you have any further questions, or mark an answer. Thanks!

Reply
Highlighted
Nintex Newbie

Re: How can I read nintext variable from C# code?

I agree with Andrew here. I would create a Nintex variable and set that variable in a SharePoint column. But I would use the SharePoint API C# code to access the value.

Reply
Highlighted
Nintex Newbie

Re: How can I read nintext variable from C# code?

I believe I have a similar question. I am creating multiple custom actions/activities and need to access a variable from the first action in an action that would be placed downstream in the workflow. I set the value of the variable in my c# code, for the first custom action. How do I access this value from the second custom action?

In the 2007 SDK, it appears there used to be an object called "CurrentWorkflowVariableValues". This does not exist in the 2013 SDK.

NWContext ctx = new NWContext(

                this.__Context,

                new Guid(this.__ListId),

                this.__ListItem,

                this.WorkflowInstanceId,

                CurrentWorkflowVariableValues,

                this);

Based on the name, it would seem like this would have provided the necessary information, however, I do not know as it isn't in the 2013 SDK. It would be great if anyone has an idea on how to access a variable that was set in the Activity class of a previous custom action.

Thanks,

Michael

Reply
Highlighted
Automation Master
Automation Master

Re: How can I read nintext variable from C# code?

In your second custom action, could you create a value that needs to be configured, but use the variable within the configuration? There are many benefits to using the variable as a configuration instead of hardcoding the reference.

Reply
Highlighted
Nintex Newbie

Re: How can I read nintext variable from C# code?

Hey Andrew,

Thanks for the response. I'm not certain I understand. Probably my inexperience with Nintex, but let me clarify my issue a bit to see if your answer is still the same.

In my first custom action, I make a REST call in my execute code of my activity. I need to pass this value through to the next action to use as part of its functionality without the end user (person setting up the workflow) ever having to specify a variable for this.

Thank you again for any suggestions!

Michael

Reply