Is there an easy way to automatically replace a charatcter entered by a user into an Infopath text box with a string of characters? - InfoPath Dev
in

InfoPath Dev

Is there an easy way to automatically replace a charatcter entered by a user into an Infopath text box with a string of characters?

Last post 10-30-2012 08:47 AM by Jammeaze. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 04-09-2012 01:43 PM

    • A_LHIN
    • Not Ranked
    • Joined on 04-09-2012
    • Posts 2

    Is there an easy way to automatically replace a charatcter entered by a user into an Infopath text box with a string of characters?

     I am new to Infopath, and I am currently using Infopath 2007 (although I could get access to 2010 if that will help...). 

    My problem is that we have created a simple form which contains a couple of text boxes.  The form is published in a Sharepoint library, and once it gets submitted, it triggers a workflow and a webservice call. 

    We have found that when users enter any of the following three characters to abbreviate their typing, "&", "<", ">", it has an adverse effect on the downstream workflow [ root cause appears to be &, as it is also a character that is used in xml for < and > ]. 

    Easy solution seems to be simply replacing any instance of these characters in the text boxes with "and", "less than", and "greater than", respectively.  However, the translate function only seems to replace these with the first character of the replacement string.

    Any suggestions would be greatly appreciated!

    Thanks!!

  • 04-10-2012 08:19 AM In reply to

    Re: Is there an easy way to automatically replace a charatcter entered by a user into an Infopath text box with a string of characters?

     Hi-

    Translate does a character per character replacement, so I don't believe it will work in this scenario. 

    I would try something like:

    concat(substring-before(yourfield, "&")," and ",substring-after(yourfield, "&"))

    Of course, the condition on this rule is that the yourfield contains &.

    Give it a shot and see if that works. Good luck!

    Ernesto Machado
    Qdabra® Software/ InfoPathDev.com
    The InfoPath Experts – Streamline data gathering to turn process into knowledge.™


  • 04-10-2012 09:22 AM In reply to

    • A_LHIN
    • Not Ranked
    • Joined on 04-09-2012
    • Posts 2

    Re: Is there an easy way to automatically replace a charatcter entered by a user into an Infopath text box with a string of characters?

    Thanks very much!  I had to make sure that whatever I use will be able to handle multiple instances of the characters appearing in the same text box, so I tried it with low expectations.  BUT, it works perfectly!! 

    Very helpful Ernesto - thank again!

  • 10-30-2012 08:47 AM In reply to

    Re: Is there an easy way to automatically replace a charatcter entered by a user into an Infopath text box with a string of characters?

    I have a similar but a little more involved scenario that I think the above formula might help solve, but I'm at a loss as to how to modify it due to lack of full understanding of how substring-before and substring-after work - especially in the above formula.

     

    I'm thinking that if one character can be replaced with a string of characters, then several characters (or a "variable") can be replaced the same way. I just need help formulating the expression.

     

    Here's a more concrete example of what I'm trying to do to help put it all into perspective:

     

    1. I have a drop down list box (LEVEL) that gets its display name data filtered from a secondary source xml file with repeating data around "meets", "needs improvement", and "exceeds".
    1. Along with each node is an element I named StarterText. Here's a snippet: NHFirstName has maintained… PRONOUN has done an outstanding… PosPRONOUN efforts have shown…
    2. Additionally, in the form I have a text box (EmployeeName) that captures the Employee Name with the expectation that it's one string, first and last name with a space in between AND a separate option button control for gender.
    3. Here's the flow I envision: Employee name is entered, the gender is selected, Meets is selected in the drop down box, the starter text is populated in the text box field (PROFESSIONAL). I've actually got working controls up to this point.
    1. This is what I want to happen next:
      1. NHFirstName in the text box field (PROFESSIONAL) is replaced with the first name in EmployeeName
      1. Every PRONOUN instance changes to "he" or "she"
      2. Every PosPRONOUN instance changes to "his" or "her"
      3. Both pronoun instances will be based on gender selection, of course
    1. So, is there a concat formula that I can put together to accomplish the above. I feel it's possible, but just out of my reach.
Page 1 of 1 (4 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.