Create Custom Inline Functions - Nintex Forms

Document created by emily.billing@nintex.com Champion on Jul 16, 2014
Version 1Show Document
  • View in full screen mode

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.

1 person found this helpful

Attachments

    Outcomes