Vadim Tabakman

Finding the position of a piece of text in another piece of text is something I've had a need to do for a while now.  It looks like someone else has had that requirement.

So I put together a very simple Inline Function.

fn-InStr

This inline function will take 3 parameters

1. Input text

2. Search text

3. Start position where to start searching.

eg. fn-InStr(abcabc,ab,2)

Installation

The assembly needs to be added to the GAC (c:\windows\assembly) on all SharePoint farm servers.  If one server is missing the assembly and SharePoint runs a workflow on that server, that Inline Function call will fail.

To install the inline function into Nintex Workflow, you'll need to run the NWAdmin.exe command line tool.  The following command line will add the inline function to Nintex Workflow.

nwadmin -o AddInlineFunction -functionalias "fn-InStr" -assembly "InStrLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=03c07361705f3bf9" -namespace "InStrLib" -typename "InStrLibMethods" -method "InStr" -description "Finds a piece of text based on a start location." -usage "fn-InStr(abcabc,ab,2)"

Once you have run this command line, perform an IISRESET.  You will then be able to use this inline function in your workflows.

Usage

To call this inline function, you can use the Build String action.  The result will need to be stored in a text variable, then you can use a Convert Value action, if you need to use it as a number.

Build String

Downloads

 InStr Assembly Download Assembly 

 Workflow : Download Test Workflow

What the Source Code looks like

        public static String InStr(String baseString, String findString, int startLocation)
        {
            String result = "";

            int iValue = baseString.IndexOf(findString, startLocation);

            result = iValue.ToString();

            return result;
        }
Posted by Vadim Tabakman Tuesday, February 26, 2013 11:29:00 AM Categories: Inline Functions Nintex Nintex Workflow Nintex Workflow 2013
Copyright Vadim Tabakman
Rate this Content 0 Votes

Comments

Monday, July 22, 2013 5:08:17 PM
Jarrad

re: Nintex Workflow - InStr Inline Function

Any chance Nintex are including an Instr function as part of the product? I've resorted to using Regular expressions a number of times instead especially in the case of finding the first or last occurance of a string.

Wednesday, July 24, 2013 9:13:09 AM

re: Nintex Workflow - InStr Inline Function

Hi JArrad,

Not as yet.  But you can email Nintex Support and they can add it to the feature request list.

cheers,

Vadim

You must sign in to this site to post comments.
Already Registered?
Sign In
Not Yet Registered?
Register

Statistics

  • Entries (279)
  • Comments (1769)

Categories