Vadim Tabakman

Inline Functions are a great extension to Nintex Workflow.  They open up the ability to do some amazing string manipulation.  But what happens when they don't work?  Why don't they work?

Scenario 1

A text variable (textSample) has the value "Hello world" and you want to replace "world" with "universe".  You can use a Build String action and a fn-Replace inline function call.

fn-Replace({WorkflowVariable:textSample},world,universe)

This will work.  The result will be "Hello universe".

What if instead, your input test was "Hello, world". - Notice the comma after the Hello.  When you run the above inline function call, it won't work and you'll get this back:

fn-Replace(Hello, world,world,universe)

Why does this happen?

The fn-Replace function supports only 3 parameters.  But the way the parsing of inline functions works, is that it first replaces any variables, fields, properties with their real values before parsing the inline function itself.  In this case, we end up with 4 parameters to the fn-Replace function call.  As it only support 3, we get the full string back.

The same sort of thing would happen if your input text was fine, but your text you want to replace or the replacement text contains a comma.

Fix

To fix this, Nintex has come u[ with a wrapping scheme, whereby you wrap any of the inline function parameters in between a {TextStart} and {TextEnd}.

So the function calls becomes this:

fn-Replace({TextStart}{WorkflowVariable:textSample}{TextEnd},world,universe)

In this case, the input is parsed correctly and the result will be "Hello, universe".

Scenario 2

Embedded inline function calls.

Again, our input will be "Hello, world" - notice the comma again.

We want to replace "Hello" with "Goodbye" and "world" with "universe".

Although we could do this with multiple Build String actions, my preference is to keep the number of actions in my workflow to a minimum.  Any time I can minimize my workflow, I do it.  It may take longer to design the workflow, or require more investigation, learning, redesigning, but I guarantee you it is worth it.  If you've ever build a large workflow ( > 1mb when you export the workflow ), you know what I'm talking about.

So the thing to take from this, is that you can call inline functions within inline functions.

eg.

fn-Replace(fn-Replace({WorkflowVariable:textSample},Hello,Goodbye),world,universe)

The above call will work, if we have no commas in our input text or other parameters.  But if you do, it'll break.

The common mistake here, is wrapping only the variable in the TextStart, TextEnd.

fn-Replace(fn-Replace({TextStart}{WorkflowVariable:textSample}{TextEnd},Hello,Goodbye),world,universe)

Also this looks like it will work, the result will be this:

fn-Replace(Goodbye, world,world,universe)

This is because the inner function call will be evaluate first.  The result will "Goodbye, world".  As you can see, there is a comma in the result and then this will be passed to the outer inline function call.  Resulting in 4 parameters being passed to fn-Replace instead of 3.

The solution to this would look like this:

fn-Replace({TextStart}fn-Replace({TextStart}{WorkflowVariable:textSample}{TextEnd},Hello,Goodbye){TextEnd},world,universe)

Where to find Inline Functions

If you can't remember which inline functions you have available, add a Build String action and in the configuration of it, click the Insert Reference button.  You'll find a tab for Inline Functions:

Inline Functions

The names you see there are the display names.  You'll find when you add them to a Build String action, they'll get a "fn-" in front of them.

Conclusion

I hope this helps people figure out why your inline functions aren't working as expected and get them working as you want.

Posted by Vadim Tabakman Friday, December 14, 2012 3:03:00 PM Categories: Build Dynamic String Inline Functions Nintex Nintex Workflow
Copyright Vadim Tabakman
Rate this Content 1 Votes

Comments

Friday, November 22, 2013 3:36:28 PM
Beulah

re: Nintex Workflow - When Inline Functions don't work

THANK you!  This was driving me batty.Smile

Thursday, May 29, 2014 8:13:32 PM
Tony
Gravatar

re: Nintex Workflow - When Inline Functions don't work

Thanks heaps...your a legend Vadim. Has been driving me crazy as well until you fab post. 

Friday, May 30, 2014 7:45:46 AM

re: Nintex Workflow - When Inline Functions don't work

That's awesome Tony.  I'm glad this helped.

cheers,

Vadim

Monday, August 4, 2014 4:02:56 AM
SOUVIK
Gravatar

re: Nintex Workflow - When Inline Functions don't work

You are Hercules of Nintex Workflow. Keep it going.

Monday, August 4, 2014 7:55:34 AM

re: Nintex Workflow - When Inline Functions don't work

hahah thanks Souvik,  I very much appreciate the compliment :).

Thursday, April 23, 2015 7:38:56 AM
Pranav
Gravatar

re: Nintex Workflow - When Inline Functions don't work

I am facing a problem in Repace function when passing parameter as an item property to it.

Thursday, April 23, 2015 7:40:00 AM

re: Nintex Workflow - When Inline Functions don't work

HI Pranav,

does your item property have any commas in it?

cheers,

Vadim

Wednesday, May 20, 2015 7:38:40 AM
Haseeb
Gravatar

re: Nintex Workflow - When Inline Functions don't work

Hi, 

I am facing issue if I have more than three variables if I checked "Parse token twice" otherwise it work only with two variables.

below is my in-line function and its result.

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

fn-Replace({TextStart}fn-Replace({TextStart}fn-Replace({TextStart}fn-Replace({TextStart}fn-Replace({TextStart}fn-Replace({TextStart}{WorkflowVariable:paramEmailBody}{TextEnd},[varWorkflowPhase],{WorkflowVariable:paramWorkflowPhase}){TextEnd},[varLastTaskRespondentDisplayName],{WorkflowVariable:paramLastTaskRespondentDisplayName}){TextEnd},[varProjectCode],{WorkflowVariable:paramProjectCode}){TextEnd},[varProjectName],{WorkflowVariable:paramProjectName}){TextEnd},[varProjectManagerName],{WorkflowVariable:paramProjectManagerName}){TextEnd},[varApproverComments],{WorkflowVariable:paramApproverComments})

fn-Replace({TextStart}fn-Replace({TextStart}fn-Replace({TextStart}

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Dear [varProjectManagerName],

The TestPhase123 has been approved by .

Project Code:
Project Name: [varProjectName]
Project Manager: [varProjectManagerName]
Project Stage: TestPhase123

Comments:

[varApproverComments]

"This is a system generated message - please do not reply."
{TextEnd},[varProjectName],){TextEnd},[varProjectManagerName],test Prog manager name){TextEnd},[varApproverComments],)

Tuesday, August 4, 2015 6:52:16 AM
Juli
Gravatar

re: Nintex Workflow - When Inline Functions don't work

Can you do the same calling an inline function within a function if you were going to do this:  fn-length(workflowvariable}fn-remove{workflowvariable}....)

Also if I do a fn-length to use with fn-remove, do I use the return from fn-length -1 as the starting point to remove the last character from the string?

Tuesday, August 4, 2015 11:02:51 AM

re: Nintex Workflow - When Inline Functions don't work

Yeah Juli,

you can embed functions within functions and you'd still need to use the TextStart and TextEnd tokens, since the data coming back from one function may have commas in the text.

You can't do math calculations like fn-length(xyz)-1.  That is not supported.

cheers.

Vadim

Thursday, October 29, 2015 9:07:12 AM
Jeff
Gravatar

re: Nintex Workflow - When Inline Functions don't work

Nintex functions fail if there is a comma anywhere in the string to be processed.  Crazy.  Never saw this crude behavior with any functions of any other language or platform.
Good luck.

Also, the functinos do not allow quoting of text to be processed, so you cannot specify special characters to be processed such as comma or semicolon without if confusing it with the syntax.

fn-Replace({WorkflowVariable:textSample},world,universe)

NOT

fn-Replace({WorkflowVariable:textSample},"world","universe")

so how would you replace a comma?

fn-Replace({WorkflowVariable:textSample}, , , ,) will, of course, not work.

 

So limiting as to be useless.

Thursday, October 29, 2015 9:13:32 AM

re: Nintex Workflow - When Inline Functions don't work

Hi Jeff,

comma's a parameter delimiters in inline function calls.  If you have text that contains commas, wrap the text or the variables or properties in {TextStart} and {TextEnd}.

That's what this article is about.  Inline functions are very powerful.  Not useless at all.

Vadim

Tuesday, December 8, 2015 8:12:47 PM
Kannan
Gravatar

re: Nintex Workflow - When Inline Functions don't work

Great post Vadim. Thanks to your post, saved us heaps of work.

Tuesday, December 29, 2015 11:09:35 PM
Ben
Gravatar

re: Nintex Workflow - When Inline Functions don't work

Would there be any reason why an inline function would return a GUID?  I had the following build string action which uses fn-Replace({TextStart}{WorkflowVariable:txtAddress}{TextEnd},/, ) I have verbose logging turned on and the before value was 'Kansas City MO 64113-2051' and the after was '2499bba4-35a2-4465-9ce4-ce11d5d0bb0'. The build string action is being used within a For Each loop where I'm looping through address lines and scrubbing them as I go. If I rerun the workflow, I may not get any GUIDs and it works as expected.  Thoughts?

Wednesday, December 30, 2015 12:36:24 AM

re: Nintex Workflow - When Inline Functions don't work

hi Ben,

not that I know of. Make sure you are running the latest build.

otherwise, contract support. That's weird behavior.

Vadim

Monday, April 4, 2016 8:41:37 PM
Michele Shaughnessy
Gravatar

re: Nintex Workflow - When Inline Functions don't work

Thanks, as always a great post

Tuesday, April 12, 2016 6:40:19 AM
Rajesh
Gravatar

re: Nintex Workflow - When Inline Functions don't work

Hi,

I want to change the "3 - Some challenges but no underlying concerns" to "In progress".

For that I am using the below function. But still I am not getting the output.

fn-Replace({TextStart}{WorkflowVariable:Proj_RAG_Status}{TextEnd},{TextStart}3 - Some challenges but no underlying concerns{TextEnd},{TextStart}In progress{TextEnd})

I am using nintex 2010.

Please help me

Tuesday, April 12, 2016 8:30:29 AM

re: Nintex Workflow - When Inline Functions don't work

Thats weird.it should work.

im not at my computer so I can't try it. The other option is to use a regular expression action to do a replace.

vadim

Friday, August 19, 2016 1:33:22 PM
Ryk
Gravatar

Thanks!

Tally another thankful customer, Vadim. This was just what I needed! yes

Friday, August 19, 2016 1:34:05 PM

re: Nintex Workflow - When Inline Functions don't work

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





 

Statistics

  • Entries (272)
  • Comments (1769)

Categories