Jump to content

JS fix for LAST, FIRST


malmazan

Recommended Posts

Hi all!

 

I'm super new to this -- -- I just went to training in early November and this is literally my second time using FusionPro for a real job -- so if this has already been answered please direct me to the right thread as I cannot find it. I'm not even sure it's possible.

 

The CSV file I have for my job has one "Name" field and within that field, the names are formatted as such: "ADAMS, MARGO" and I want that to return "Margo Adams".

 

I was able to use a basic rule to fix the all caps problem, but I have NO CLUE on what javascript to write to force anything after the comma to go first and anything before the comma to go last then delete the comma.

 

I think I need the JS to include the Title Case functionality as well as the correct formatting functionality, correct?

 

It seems like this might be a fairly common issue with customer-provided lists, so if it's not possible, I'm A-OK with telling the customer to fix their formatting. :D

 

Thanks so much for your help!

Link to comment
Share on other sites

var fullName = Field("Name").split(", ").reverse();
return ToTitleCase(fullName.join(" "));

Of course, this is dependent on EVERY record having a value of [LAST, FIRST]. If any record has first name first, or is not separated by a comma-space, or has a middle initial, the result will be incorrect. Sometimes it is advisable to make data changes "upstream" in the process (i.e. in a spreadsheet app before linking in FusionPro). :)

Link to comment
Share on other sites

Eric -- THANK YOU SO MUCH. This Thanksgiving, I am thankful for you!

 

I did have a bit of clean up to do in the database, but nothing a find-and-replace doesn't fix quickly. I will keep this code forever!

 

Thanks for your help and quick reply!

 

Mariah :)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...