Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Slice or dispaly Last,First,Middle name where each column has a char limit

Community Beginner ,
Nov 08, 2016 Nov 08, 2016

Good morning Adobe community,

Our current forms mapping is setup to display a member's name by the following order. Last,First,Middle in a single field (ie Johnson,Gary S). Where Last,First,Middle have their own column with character limit in our table dictionary. There is only a space between first name and middle.

Char Limits for each column:

Last 80

First 20

Middle 20

I'm trying to break the names apart (similar to slice) and re-display the name in a single field such as: Gary S Johnson. Were each name char limit varies. Is this possible? I appreciate any assistance as this is beyond me.

Phil

TOPICS
Acrobat SDK and JavaScript
685
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 08, 2016 Nov 08, 2016

This is tricky... You can try to split the string with the comma to two parts and then split the second part into words, taking the last item to be the middle name, if it's all-caps, I guess.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 08, 2016 Nov 08, 2016

My thoughts were the same but that's where my brain capacity hit the ceiling.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 08, 2016 Nov 08, 2016

try67, In the example name above, Johnson,Gary S

is there a way to write two parts, 1) "Give me everything before the comma and send to field1" and 2) "Give me everything after the comma and send to Field2"? 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 08, 2016 Nov 08, 2016

Sure. As the custom calculation script of Field1 enter this code:

var fullName = this.getField("FullName").valueAsString;

if (fullName=="") event.value = "";

else event.value = this.getField("FullName").valueAsString.split(",")[0];

And do the same for Field1, replacing [0] with [1] in the last line.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 08, 2016 Nov 08, 2016

That resolved my issue. Thank you! I'm new to the infinite things you can do with split().

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 08, 2016 Nov 08, 2016

Not to burst your bubble, but you can do exactly one thing with the split method: Split a string using a delimiter into an array.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 08, 2016 Nov 08, 2016

I appreciate all your advice. The solution is a "good enough for Government work" scenario. There are a few other examples i'd hate to ask. The end goal is to have this name populated in a single fill-able field PDF letter. But there are those unique, foreign names that become a challenge. Such as names or last names with spaces or hyphens.

Overall goal:

Dr Mr/Mrs  [Main_Field],

Other combo examples are:

Johnson-Walters, Mary Jane

Jonson Walters, Billy Joel Sr

Amerson-Jay Colby, Gary Jr

In all three names, the comma is consistent in dividing Last & First. And if he's a Sr/Jr, that is always after the first name with space.

This is where I yet to grasp the knowledge in how to take advantage of delimiter in array.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 08, 2016 Nov 08, 2016
LATEST

This is exactly the reason you should not attempt to do what you're doing. The chances of getting it wrong are not slim, and if you do get it wrong it can piss people off. It's better to let people enter their own names than try to guess what they should be.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines