Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
My thoughts were the same but that's where my brain capacity hit the ceiling.
Copy link to clipboard
Copied
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"?
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
That resolved my issue. Thank you! I'm new to the infinite things you can do with split().
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now