• vadim@workflowexcellence.com
  • Utah, United States

Nintex Workflow – Trigonometry (why?….why not?)

Earlier last year, I was curious about performing some Trigonometry calculations in a Nintex workflow and was wondering how to do it. Out of the box, there didn’t really seem to be an easy way to do it.

I have 2 options.

1. Create a custom action that performed them.

2. Build the algorithm into workflow.

Just for kicks I built an approximation algorithm, to give me the result of sin(radians). You are probably asking why? I just wanted to see if I could do it. Note : I found the algorithm here How does the calculator find values of sine This algorithm will give you an approximation of the result of a sine calculation, but for the purposes of the test, it was good enough. Here is the workflow that reproduced the algorithm in using Nintex Workflow :

Download MathSinWorkflow

As you can see, this isn’t the smallest of workflows, and although I could have made it a little neater using a State Machine, I just chose to do some cut an pasting. The final result is that I did get what I expected, which is an approximation of the calculation for a trigonometric sin operation. Then came the release of Build 10906 of Nintex Workflow (I think it was 10906. Maybe it was 10903.. don’t think is matters now), and the Workflow team implemented In-line Functions. These are a great way of extending Nintex Workflow, and are completely underutilized. Having come from development background, I decided to add 3 new In-line functions. The best part is, I didn’t even have to do any coding.

1. Open SQL Management Studio

2. Navigate to the NW2007DB database 3.

Open the “String Functions”

4. Add the following 3 lines to give you Sin, Cos and Tan functionality

5.

6. Actually, it’s preferable not to add the inline function to Nintex Workflow using the NWAdmin.exe command line tool.  It has a -o AddInlineFunction operation, so you don’t have to directly manipulate the Nintex Workflow database.

You will now have the following In-line Functions available to you : fn-Sin, fn-Cos, and fn-Tan. This is strictly using the .Net Math class, and I knew that they have Sin, Cos and Tan functions that we could utilize. .System.Math Methods This opens up Nintex Workflow to many possibilities. If .Net does not already have the class and method that you need to use, then it wouldn’t be too hard to make an assembly that exposes that functionality. You would need to make sure it’s deployed to all WFE’s and probably Application Servers as well, but it’s much easier and quicker than building a complex workflow or even

developing a custom Workflow Action. Taking this into account, my workflow have now changed to this :

Download MathSinInlineWorkflow

Vast improvement from ~39 actions to 3 actions. So although when you design your workflow, it might look extremely complicated at the start, over time, as you get a better feel for Nintex Workflow, you will find that there are some interesting way of improving your workflow design for quicker design, and easier maintenance in the future.

Leave a Reply

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