Return the first character in a field - InfoPath Dev
in

InfoPath Dev

Return the first character in a field

Last post 06-04-2007 12:55 AM by Matt Faus. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 05-31-2007 06:31 AM

    Return the first character in a field

    I am creating a welcome package for new employees in my company. One of my fields needs to be autofilled with the the contents of one text box and the first character of another text box.

     I know how to concat. 2 full text boxes together but I need help in returning just the first character of the second text box.

    Any suggestions?

  • 05-31-2007 06:57 AM In reply to

    Re: Return the first character in a field

    Hi,

    I would do that in code. See example below:

    var contentOfTextBoxOne = XDocument.DOM.selectSingleNode("my:myField/my:textBoxOne").text;

    var temp = XDocument.DOM.selectSingleNode("my:myField/my:textBoxTwo").text;

    var firstCharacter = temp.substring(0,1);

    var concatString = contentOfTextBoxOne + firstCharacter;

    Does this help ?

    Listen to Motörhead cos they play Rock'n Roll :)
  • 05-31-2007 08:39 AM In reply to

    Re: Return the first character in a field

    Thanks for the quick reply.

     I didn't end up using your suggestion though, as a co-worker gave me an easier solotion with no coding involved.

    I entered the following formula into default value of the text box where I want the result:

    concat(textboxone, substring(textboxtwo, 1, 1))

    It appears to work like this.

  • 06-04-2007 12:55 AM In reply to

    Re: Return the first character in a field

    A formula is definitely the way to go here.  No need to add extra code when it's unnecessary.
    Matt Faus / Microsoft InfoPath MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
Page 1 of 1 (4 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.