Nintex Connect

The Official Community Site for Nintex Software Products, including Nintex Workflow 2007, 2010 and 2013; Nintex Workflow for Project Server 2010; Nintex Reporting 2008 and Nintex Analytics 2010; Nintex Forms 2010; Nintex Live and Nintex SmartLibrary.
Welcome to Nintex Connect Sign in | Join | Help
in Search

fn-Remove inline - output error - extra characters

Last post 06-05-2012, 1:13 PM by kdavis4. 2 replies.
Sort Posts: Previous Next
  •  05-24-2012, 3:34 PM 23147

    fn-Remove inline - output error - extra characters

    I am attempting to use the inline function fn-remove to trim excess text from a field that may have a large amount of text.  My objective is to keep only the first 200 characters and assign them to variable txtRiskDescription. 

    I use the same series of actions described in this post: http://connect.nintex.com/forums/thread/22593.aspx

    My field is read from a list into variable txtRiskDescription, and may contain one or many sentences, including punctuation. 

    I did discover that I have to use {TextStart} and {TextEnd} in order to get the Length (Step 1 from the example at the link above) because my data may have commas or other special characters: fn-Length({TextStart}{WorkflowVariable:txtRiskDescription}{TextEnd})

    In some cases I will have only 10 characters, and in some cases up to 10000, so I use fn-Length and an If/then to test for greater than 200 characters, and if so, execute the fn-remove. 

    In my loop (step 4) my configuration to remove text is:  fn-Remove({WorkflowVariable:txtRiskDescription},200)    .........  assigned to back to the same variable txtRiskDescription

    I output txtRiskDescription into the history list log to check the new truncated value.   In cases where there are less than 200 characters, the output is the contents of txtRiskDescription (as expected).

    In cases where there are more than 200 characters, the output is: fn-Remove(<div>Text here that has been truncated to 200 characters

    I underlined the extra characters that are being assigned to the txtRiskDescription variable.  Why are these characters "fn-Remove(<div>" present?  I do not see the error in my configuration (above, step 4).  ???

    Thanks

    Filed under:
  •  05-28-2012, 1:06 AM 23180 in reply to 23147

    Re: fn-Remove inline - output error - extra characters

    Hi,

    In regards to the <div>, in some fields such as HTML enhanced multiline text field SharePoint inserts some extra text around the HTML.

    As to your other issue, I recommend you wrap all inputs with {TextStart} and {TextEnd} even in the fn-Remove() inline function.

    As a first step in each case you may want to use a regular expression to remove <div> and </div> from the text input before running it through any inline functions.

  •  06-05-2012, 1:13 PM 23303 in reply to 23180

    Re: fn-Remove inline - output error - extra characters (new fn-Length problem)

    I've made progress on this by using Regular Expression (Extract) with the expression (?<=^|>)[^><]+?(?=<|$) to remove the extra HTML characters.  My ultimate goal is to truncate a multiline text field to a specific character limit.  I'm almost there but have discovered a new problem with the fn-Length function.   Here are the steps I have:

    1. After reading in the multiline text field into a variable, remove the extra HTML by using RegEx with the expression above.  Output this result into colRiskDescript
    2. Collection action - Get the first item from the collection into a text field: txtRiskDescriptionOut
    3. Find out the character length of the above: fn-Length({TextStart}{WorkflowVariable:txtRiskDescriptionOut}{TextEnd})    and drop the results into a variable txtRiskDescripLength
    4. Convert txtRiskDescripLength to numeric: numRiskDescripLength
    5. Condition action, test whether numRiskDescripLength > 200, if so, do the truncation
    6. Truncation: fn-Remove({TextStart}{WorkflowVariable:txtRiskDescriptionOut}{TextEnd},200)(...)

    Steps 1-6 work successfully under most conditions and produce the truncated output followed by (...).  However, there is one problem.  When the input text (from step 1) contains double enter (to separate paragraphs), fn-Length stops counting after the first paragraph.  See below for an example:

        

    Example 1:
    This long paragraph is 323 characters and fn-Length will count the entire amount of text correctly, regardless of whether it wraps within the multiline field or not.  It will continue to count until the end of the text and all the steps above (from 1-6) will work successfully, resulting in truncated text, followed by (…).
        

    Example2:
    However, if I have multiple paragraphs, like this.  

    The fn-Length count will be 50, when it should have been 239.  Fn-Length stops counting after the first paragraph and does not count the entire amount of text in the entire multiline field. 

    My users tend to enter a mix of text into the multiline field and often in paragraph form separated by enter/enter.  This throws off the fn-Length count.  Notice I used {TextStart}{TextEnd} on fn-Length as well as fn-Remove.  I thought this would solve the problem but it doesn’t.  Any ideas?

    Filed under:
View as RSS news feed in XML
Powered by Community Server, by Telligent Systems