Jump to content

Empty field and extra spaces


Recommended Posts

This is probably in the forum somewhere, but I cannot find it at the moment and have already spent WAY more time than I should to compose this job!


Mac version FusionPro Desktop 7.2P1k


I have the following fields: Salutation, First Name, Middle Name, Last Name, Suffix.


There are records that have none of the above, so I have created a rule that says if no name, replace with Valued Customer. I added a field to the csv file to that effect, so that I could create a simple rule. I also need to eliminate any extra spaces that might appear if there is no suffix, and also if there is no middle name, since some of the records have first and last but no middle. I'm have a HECK of a time making EVERYTHING work. I can get the first middle last to behave, but then when I come across a first and last only, I get an extra space for the middle. If I take out the space in the rule, then it smashes everything together. HELP, please!!! Here's the formula:


if (Field("First Name") == "") {

return Field("If no name")}


return Field("First Name")+" "+Field("Middle Name")+" "+Field("Last Name")


if Field("Middle Name") =="")

return Field("First Name")+" "+Field("Last Name")

Link to comment
Share on other sites

You just have the sequence a little messed up. Try this:


if (Field("First Name") == "")
return Field("If no name");
else if (Field("Middle Name") == "")
return Field("First Name")+" "+Field("Last Name");
return Field("First Name")+" "+Field("Middle Name")+" "+Field("Last Name");


There are better ways to error proof this but this should at least work.

Link to comment
Share on other sites

That worked AWESOME except that I don't think I can use my suffix rule, and I'm not getting the space between the last name and the suffix... where do I put that? I tried tacking it onto the end of what you gave me, including the additional space, and it's ignoring me.
Link to comment
Share on other sites

It's hard to see what you mean without seeing the script you have. I would replace the whole thing with this:


var NoName = Field("If no name");
var FName = Field("First Name");
var MName = Field("Middle Name");
var LName = Field("Last Name");
var Suffix = Field("Suffix");
var sp = " ";

if (FName.length > 0)
FName += sp;
if (MName.length > 0) MName += sp;
if (Suffix.length > 0) LName += "," + sp + Suffix;

return FName + MName + LName;
return NoName;


It sets up a variable for each field then appends spaces or the suffix if needed.

Link to comment
Share on other sites

Beautiful! That worked! Thank you so much for saving my sanity! I knew I was on the right track, but I didn't know if I was setting it up in the right order or not, or what I was doing wrong. Code is way over my head sometimes...


Thank you so much!

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.

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...