Splitting full name into first and last

markdown18.2

This is a very useful feature. Sometimes we need to break a full name into two Text fields that will include the first name and the last name.

For example, you are given the full name:  Pedro de la Maria de la Dolores

If you want to use first name: Pedro and last name: Dolores, that can be easily done with the following two Javascripts:

For first name:

var full = @Full name updated;
   var broken = full.split(” “);
   broken[0].toString() 

/* ——————————————————————————————————-

Created by BendixKiel ApS – Copenhagen based Podio Preferred Partner -with more than 6 years of experience in helping organizations implement Podio. Please feel free to contact us if you need help evaluate, structure or implement Podio in your organization.

BendixKiel ApS www.bendixkiel.org +45 71 99 05 80 anders@bendixkiel.org

———————————————————————————————————– */

 

For last name:

var full = @Full name updated;
var broken = full.split(” “);
broken[broken.length – 1] 

/* ——————————————————————————————————-

Created by BendixKiel ApS – Copenhagen based Podio Preferred Partner -with more than 6 years of experience in helping organizations implement Podio. Please feel free to contact us if you need help evaluate, structure or implement Podio in your organization.

BendixKiel ApS www.bendixkiel.org +45 71 99 05 80 anders@bendixkiel.org

———————————————————————————————————– */

Don’t forget to replace the @Full name updated with your own full name Text field.

Maybe you don’t want to miss information from the full name, meaning that you would like to use first name: Pedro, and then last name: de la Maria de la Dolores

In this case you need to use the following Javascript as last name:

var full = @Full name updated;
var broken = full.split(” “);
var i = broken.length;
switch(i){
    case 0:
    case 1:
         undefined
         break;
    case 2:
         broken[1].toString()
         break;
    case 3:
         broken[1].toString() + ” ” +
         broken[2].toString()
         break; 
    case 4:
         broken[1].toString() + ” ” +
         broken[2].toString() + ” ” +
         broken[3].toString() 
         break;
    case 5:
         broken[1].toString() + ” ” +
         broken[2].toString() + ” ” +
         broken[3].toString() + ” ” +
         broken[4].toString()
         break;
    case 6:
         broken[1].toString() + ” ” +
         broken[2].toString() + ” ” +
         broken[3].toString() + ” ” +
         broken[4].toString() + ” ” +
         broken[5].toString()
         break;
    case 7:
         broken[1].toString() + ” ” +
         broken[2].toString() + ” ” +
         broken[3].toString() + ” ” +
         broken[4].toString() + ” ” +
         broken[5].toString() + ” ” +
         broken[6].toString()
         break;
}

 /* ——————————————————————————————————-

Created by BendixKiel ApS – Copenhagen based Podio Preferred Partner -with more than 6 years of experience in helping organizations implement Podio. Please feel free to contact us if you need help evaluate, structure or implement Podio in your organization.

BendixKiel ApS www.bendixkiel.org +45 71 99 05 80 anders@bendixkiel.org

———————————————————————————————————– */

Don’t forget to replace the @Full name updated with your own full name Text field.

 

Thus, the following changes in “Modify Template”

markdown18.1a

markdown18.1b

 

give us the following result

markdown18.2

 

No comments yet.

Leave a Reply