Skip to main content
Nintex Community Menu Bar

Turn ID into a 3 character string / Get the last 3 characters of a string / TRUNCATE

  • June 23, 2019
  • 5 replies
  • 19 views

Forum|alt.badge.img+1

I'm trying to get the ID of an item and make it a three digit number string.

 

I have tried multiple solutions. My most recent is this inside setting a variable

fn-Substring(fn-PadLeft(2,{WorkflowVariable:Oid},00),fn-Length(fn-PadLeft(2,{WorkflowVariable:Oid},00))-3,3)

 

If Oid = 11 I would expect the result to be 011

The log says Oid: 11 and varOrderID:

I have also tried using a calculated field on the list that has a 3 digit number like I want and use the Query a List action to retrieve the calculated field but that also returns with no result.

5 replies

Forum|alt.badge.img+14
  • Scholar
  • June 24, 2019

first of all, check the correct syntax for single inline functions.

eg. PadLeft's first argument should have been source string ...

https://help.nintex.com/en-US/nintex2013/help/#Workflow/RootCategory/Designer/Nintex.Workflow.InlineFunctions.htm

 

 

at second, I think regular exprassion would be much easier for this task.

try following

2734i7877FF8C9A3BF1EA.jpg

 

regular expression pattern:

 

.{3}$

 

 


Forum|alt.badge.img+1
  • Author
  • July 4, 2019
Almost solves it but it adds a semicolon to the end

Forum|alt.badge.img+14
  • Scholar
  • July 4, 2019

"it" doesn't return any semicolon... => can you see it in RunNow output?

 

RE's extract operation always returns a collection. and it has to be aproached that way.

if you approach it differently, eg. as a single line text value, you might see semicolon(s) there, which is collection elements separator

 


Forum|alt.badge.img+7
  • July 5, 2019
Hi I do this to get my 0000025 ID text number...

Build String Action...

fn-Substring(0000000{ItemProperty:ID},fn-Length({ItemProperty:ID}),7)

Adjust the number of Zeros and Length as required.


Forum|alt.badge.img+14
  • Scholar
  • July 8, 2019

2nd parameter of fn-Substring() defines a position where it should start copy from.

so if your ID is 11, it's length is 2, so you get substring copied starting from 2nd position...

 

I'm affraid, you will not achieve what you want with fn-Substring(), unitl you calculate correct start position in a compplicated way.

use a regular expression approach as suggested, that's much easier.