3 first letter from name and surname
Hello, I have a small problem, I want to create a unique ID contains the first 3 letter of name and surname, which are in one field.
So I have field with name and surname: John Smith
And I want in my ID: JohSmi
What should I write in my calculation field? Please some help :)
-
Hi Sandra
there's a typo in Hamid's code, must be
var b = @NameField.split(" ")[1].substring(0,3)
Another issue: If there's a middlename like John Richard Smith the result would be JohRich. Middlenames could be handled in the code:
var a = @NameField.split(" ");
var b = a[1].substring(0,3);
var c = a[a.length -1].substring(0,3);
b+cBut what about names with a suffix like John Smith jr. or a prefix Dr. John R. Smith or J. R. Smith? Or if you have John Smith and Johanna Smitter - both would have the same ID. Or Jo Smith = JoSmi (5 characters only).
What I want to say: It's very difficult and dangerous to create an ID by using names. It only works correctly if everyone enters their names correctly and always in the same format.
Rainer
Please sign in to leave a comment.
Comments
5 comments