Nintex Workflow – Enhancing Nintex Workflow through Nintex Workflow

Interesting title for a blog entry right?

Inline Functions in Nintex Workflow really enhance the product, without having to go to the complexity of creating a custom Nintex Workflow action. Granted, this only works with static methods that return a value such as a string or integer. The one caveat, is that you may need a techie brain to be able to add a new inline function to the Nintex Workflow database, so that it would become available to your users. In an example that I used in my previous blog entry – Nintex Workflow – Trigonometry (why?….why not?), I used some of the Math methods that are available in the System namespace, and the Math class.

So to add an Inline Function to Nintex Workflow, you would open the NW2007DB database and add an entry into the StringFunction table or use the NWAdmin command line utility. In most organisations, you don’t really want to allow direct access to production servers or databases. So I came up with a really simple way of allowing a user to add an Inline Function, by using a Nintex Workflow itself.

List

The first step was to create a SharePoint list with 5 new columns (all text strings): Function Alias Method Name Assembly Name Namespace Type Name These map directly to the fields in the StringFunction table in the Nintex Workflow database. What we want to do here, is allow a user to enter all the details required for the Inline Function, and then have a workflow run off this information and add the Inline Function to the Nintex Workflow database. We have to make sure that an entry doesn’t already exist in the table so that we don’t mess up the table.

Workflow

The Execute SQL action is going to be out best friend in this workflow. It’s a simple workflow. Use the Execute SQL action to check if the Inline Function already exists in the database. If it doesn’t, use another Execute SQL action to add the entry to the database. Finally, delete the SharePoint list item from the list, as we no longer need it. As an example, I am going to use the System.Math class and the Abs method. This method returns the absolute value of a specified number. eg. it takes 1.23 and returns 1. Our SharePoint list item would look like this : Functon Alias : fn-Abs Method Name : Abs Assembly Name : mscorlib Namespace : System Type Name : Math In order to check if the Inline Function already exists, my first Execute SQL action will perform the following query : SELECT count([FunctionAlias]) FROM StringFunction WHERE [FunctionAlias] = ‘{ItemProperty:Title}’ This gets a count of all the Inline Functions that have a FunctionAlias the same as what our user has entered into our SharePoint list item. This is stored in a number Workflow variable (numCount) for us to use in the Set a Condition action next. We then check to see if variable (numCount) is equal to 0. This means that this Inline Function does not already exist. We can therefore proceed to add this Inline Function to the database. Our next Execute SQL action, performs and Insert Query.

  INSERT INTO [StringFunction] ([FunctionAlias] ,[MethodName] ,[AssemblyName] ,[Namespace] ,[TypeName])
VALUES ('{ItemProperty:Title}',
'{ItemProperty:Method_x0020_Name}',
'{ItemProperty:Assembly_x0020_Name}',
'{ItemProperty:Namespace}',
'{ItemProperty:Type_x0020_Name}')

You can put in some error handling to confirm that this action completes successfully. For this article, I haven’t chosen to do that. For a production environment, I’d recommend it. Now that the entry is added to the database, we can run a Delete an Item action, to delete this SharePoint list item (cleaning up). We are now able to use this new Inline Function in other workflows.

Workflow Screenshot

Useful Files

Download Add NW Inline Function.stp

Download AddNWInlineFunctionWorkflow.nwf

Leave a Reply

Your email address will not be published. Required fields are marked *