Calculating last name from the built-in contact field

Comments

5 comments

  • Official comment
    Jacquelyn May

    Hi Bumble,

    I'm afraid there wouldn't be a way to do this, since you cannot use Contact fields as variables in a calculation field. Is it possible to store your contacts in an app instead of using Workspace contacts?

    https://help.podio.com/entries/27368048-Importing-Contacts-Using-a-Contacts-app

    That way you could store first/last names in different fields right from there.

    Do you think that could work?

    /Jacquelyn - Podio

    Comment actions Permalink
  • Rainer Grabowski

    Hi Bumble,

    if I understand you right, you have a contact field/Type Workspace contacts. There must have benn a misunderstanding by Jacquelyn - or by me) - but that contact field is available as a variable in a calculation field., But only the content of Name field. @contact returns the content as an array, you have to parse it to a string bei adding .join()

    To get the name of the contact you can do:

    @contact.join()

    That shows you the name, how it is entered. Normaly "FirstName LastName" or "FirstName MiddleName LastName".

    The LastName you can extract:

    var fullname = @contact.join();
    fullname.substring(fullname.lastIndexOf(" "));

    This works fine if there is no suffix like "FirstName LastName, jr." or "FirstName LastName jr.". You can do some checks if there's a suffix.Often a suffix contains a dot or is separated by a comma.

    fullname = @contact.join();
    getLastString = fullname.substring(fullname.lastIndexOf(" ") );
    check = getLastString.indexOf(".") > -1 || fullname.indexOf(",") > -1 ? fullname.substring(0,fullname.lastIndexOf(" ")) : fullname;
    lastname = check.substring(check.lastIndexOf(" "));
    lastname.replace(",","")

    This doesn't cover all possible cases , e.g. for a name entered as "FirstName LastName junior" the result would be "junior" or for "LastName Firstname" = FirstName, but the result for "LastName, FirstName"  would be "LastName"

    Rainer
    rg@delos-consulting.com

     

    1
    Comment actions Permalink
  • Paul Self

    Has then been any solution to "unsimplifying" the Contacts field and being able to extract a First Name? Every App for contacts I make has to be created seperatly so that I can get First.

    0
    Comment actions Permalink
  • Helge Klein

    Luckily Jacquelyn's answer is incorrect. As Rainer explained the way to get the name from a contact field in a Podio calculation is:

    @contact.join()
    0
    Comment actions Permalink
  • Rainer Grabowski

    @helge
    Have a look at the date of Jacquelyn's answer: July 16, 2014
    The calculation fields have been introduced some weeks before, in May 2014 (if I remember right). And at that time not all field types have been available in calculation fields. E.g. Contacts have been added a bit later. So for July 16, 2014 Jacquelyn's  answer has been correct.   

    Rainer

    0
    Comment actions Permalink

Please sign in to leave a comment.

Powered by Zendesk