Extract initials from name - InfoPath Dev
in

InfoPath Dev

Extract initials from name

Last post 04-21-2014 08:34 AM by Jimmy. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 04-11-2014 02:07 PM

    • DWTKENT
    • Not Ranked
      Male
    • Joined on 04-04-2011
    • Toronto
    • Posts 10

    Extract initials from name

     Hello all,

    I have a field called [ProjectIni] that want the value to be the initials of a text field called [ProjectName]. The text field can have multiple words in it however the formula I'm using is only extract the first letter from the first word and the first 2 letters from the second word.

     concat(substring(Project, 1, 1), substring(substring-after(Project, " "), 1, 1), substring(substring-after(Project, " "), 2, 1))

     This is fine if the ProjectName is only one or two words, however that is rarely the case.

    What am I missing? I can't for the life of me figure out why I can't use three or four words in [ProjectName]

     

    any ideas?

    d

  • 04-15-2014 01:30 PM In reply to

    Please see attached.

    It works up to 15 spaces, Infopath limitation.  Hopefully that is enough for what you need.  You could get it to do more if using code, but a rules based version works for most cases.

    I got it to work using 3 fields. 2 of them can be hidden.

    Field 1 is the input field.

    Field 2 is an eval field that checks if field 3 has any " " in the field

    Field 3 is the finished field

    Field 4 is a counter field

    If you look at each field you can see the rules applied to them.

    Field 1 has 1 rules, it copies itself into Field 3 and sets Field 4 to 0.
    Field 2 has no rules.
    Field 3 has 3 rules, one that evals to Field 2, one that adds 1 to field 4 and concats back on itself, and one that finishes the concat when there are no more " "
    Field 4 has no rules

    There may be a better way to do this, but this way works.

  • 04-16-2014 07:30 AM In reply to

    • DWTKENT
    • Not Ranked
      Male
    • Joined on 04-04-2011
    • Toronto
    • Posts 10

    Re: Extract initials from name

     WOW, thanks leoffneym,

     

    That was exactly what I needed. It was so much easier to accomplish in excel. Thanks for your help.

     

    DWTKent

  • 04-21-2014 08:34 AM In reply to

    Re: Extract initials from name

     If your form has qRules in it, there should be a fairly easy way to do this using the Replace command, but I don't entirely understand your original post. You are taking the first letter from the first word, and the first two letters of the second word. What are the logistics in play there? What would be the desired output if there were three words?

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
Page 1 of 1 (4 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.