cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Create Custom Inline Functions - Nintex Forms

What are inline functions?

Inline functions are used within Nintex Forms to perform a variety of different operations performed on the Server. Custom inline functions can be created within Visual Studio for use within Nintex Forms. In this article, we demonstrate how you can create additional custom inline functions for use in Nintex Forms (2013 and 2010).

A custom inline function may be able to leverage functionality from the .NET library. One such example is generating a Random number for use within a form with the .NET library Random number generator.

Once you have created a new inline function it will be available in the Insert Reference dialog of Nintex Forms controls.

Pre-requisites

  • All versions of Nintex Forms
  • Any version of Visual Studio with .NET 3.5

Requirements

The requirements for a function to be used by Nintex Forms are:

  • The function must be a static method
  • The function accepts parameters that can be parsed from text
  • The assembly is signed and built as a Strongly Named assembly
  • The function is contained in a type installed into the GAC on each web front end

Aliases

A function is referred to by its alias. A function can have multiple aliases to cater for localization. Localization of function names is done by adding a new alias for each language.

Creating an Inline Function - Random Number Generator

In this article, we’re going to step you through how to create a random number generator function. You may use this in cases where an unpredictable result is desired.

  1. Create a new class project in Visual Studio. In the Application section, select .NET Framework 3.5 as the Target framework.
    custom.png
  2. Sign the Assembly. Open the Signing section, and supply your strong name key file, or create a new one.
    assembly.png
  3. Within Visual Studio, create a Static class with a static method. In this example we will create a Random function which will return a random number.
  4. Compile the project within Visual Studio.

using System;

namespace CustomInlineFunction

{

    public static class InlineFunctions

    {

        public static int Random()

        {                           

            Random randomNumber = new Random(Environment.TickCount);

            return randomNumber.Next();

        }

    }

}

  1. Register the output dll to the GAC using the gacutil utility.

    gacutil /i "C:\Projects\CustomInlineFunction\bin\Release\CustomInlineFunction.dll"

  2. Add the inline function to Nintex Forms via the PowerShell command Add-InlineFuction.

    Add-InlineFunction -FunctionAlias "fn-CustomRandom" -AssemblyName "CustomInlineFunction, Version=1.0.0.0, Culture=neutral, PublicKeyToken=c559cde2944155fd" -Namespace "CustomInlineFunction " -TypeName "InlineFunctions" -MethodName "Random" -Usage "fn-CustomRandom()" -Description "Returns a random number"

  3. The function should now be available in Nintex Forms.

How to access the Custom Inline Function:

Click on any field with an Insert Reference icon, select the Inline Functions tab, and the new inline function should appear in the list.

Labels: (1)
Reply
7 Replies
sritzel
Nintex Newbie

Re: Create Custom Inline Functions - Nintex Forms

Can I put multiple functions in the same .dll?

0 Kudos
Reply
vadim_tabakman
Nintex Newbie

Re: Create Custom Inline Functions - Nintex Forms

Hi Stephen,

yes you can have as many static functions in the same assembly as you need.

cheers,

Vadim

0 Kudos
Reply
cassymfreeman
Nintex Newbie

Re: Create Custom Inline Functions - Nintex Forms

what sort of things have people used this for?

0 Kudos
Reply
vadim_tabakman
Nintex Newbie

Re: Create Custom Inline Functions - Nintex Forms

Hi Cassy,

I've used it in the past to expose from static .Net functions, like Regex.Match or even expose it a little more by wrapping it into my own.

In my example, I found that the Regular Expression actions, when doing in an Extract always returned a collection.  In a large workflow I was building, I needed that functionality, and I knew I would only ever get back one piece of text.  So I made an Inline function that would do that and I could use it in a Build String action.  It let me reduce the size of my workflow a little.

Vadim

0 Kudos
Reply
cassymfreeman
Nintex Newbie

Re: Create Custom Inline Functions - Nintex Forms

thanks Vadim Tabakman​ - it's definitely something to keep in mind.

0 Kudos
Reply
mohammad_mavia1
Nintex Newbie

Re: Create Custom Inline Functions - Nintex Forms

Hi,

I have performed everything like it is mentioned here 
but my function is not working.
i have put it in a Default value of a Text box, instead of running the function it copies the name of the function in the default value of the text box as mentioned in the image.

below is my function and the command  have write

namespace IsEnglish
{
public static class Function
{
public static string Is_English()
{
var _lcid = System.Threading.Thread.CurrentThread.CurrentCulture.LCID;
var _lcidUI = System.Threading.Thread.CurrentThread.CurrentUICulture.LCID;

return "LCID: "+_lcid+" LCID-UI: "+_lcidUI;
}
}
}

 

Command:
Add-InlineFunction -FunctionAlias "fn-CustomIsEnglish" -AssemblyName "IsEnglish, Version=1.0.0.0, Culture=neutral, PublicKeyToken=c559cde2944155fd" -Namespace "IsEnglish " -TypeName "Function" -MethodName "Is_English" -Usage "fn-CustomIsEnglish()" -Description "Returns a lcid"

0 Kudos
Reply
nils_a
Nintex Newbie

Re: Create Custom Inline Functions - Nintex Forms

Has anyone ever tried adding the function (i.e. calling Add-InlineFunction / NWAdmin.exe -o addinlinefunction) by usage of the LCID 1033 instead of no lcid? The outcome (at least in Nintex Workflow 2010) is quite funny...

0 Kudos
Reply