Info-Path - how to split a string into 2 substrings

3.7k views Asked by At

Hi i am using microsoft infopath to create forms for sharepoint and i was wondering how to auto populate fields with sub strings. Basically i have 3 fields; full name , first name and last name. the full name field is a drop down list containing full names. i want first name and last name to be populated based on the full name selected. so if for example say someone selects the full name "joe bloggs" from the drop down list, this selection will populate the first name field with "Joe" and the last name field with "bloggs" automatically. can i use a function in infopath to split the full name string into 2 sub strings (first name and last name). ?

2

There are 2 answers

0
user2051770 On
  1. Add a rule to your Full Name dropdown for when the field changes
  2. Add a new action to the rule to set the value of the First Name field to: substring-before(<full name field>, " ")
  3. Add a new action to the rul to set the value of the Last Name field to: substring-after(<full name field>, " ")

Note that the above assumes you only have TWO names in the Full Name list.

0
Marwa Abdel Rahman On

Add rule for full name field to take action and set value for first , Middle and last name as following:

First = substring-before(Full Name, " ")
Middle = substring-before(substring-after(Full Name, " "), " ")
Last = substring-after(substring-after(Full Name, " "), " ")

Good Luck.