Jump to content

Inserting a comma between fields


wellers_97

Recommended Posts

First off I'm fairly new to fusion pro so forgive me for my simple questions. I am creating a business card for Digital Store Front and some cards will have just a Full Name and others will also include credentials. When credentials are present I need a comma after the Full Name field.

 

Example:

 

John Doe

John Doe, DMD

 

I know this is a very simply thing but nothing I have tired has worked so far. Help!

Link to comment
Share on other sites

This should do it

if ((Field("Full Name") != "") && (Field("Credentials") != ""))
return Field("Full Name") + ", " + Field("Credentials");
else if ((Field("Full Name") != "") && (Field("Credentials") == ""))
return Field("Full Name");
else
return "";

There are quite a few ways to do this. Here are a few more:

var result = Field("Full Name");
if (result && Field("Credentials"))
 result += ", " + Field("Credentials");
return result;

 

return [Field("Full Name"), Field("Credentials")].filter(String).join(", ");

 

return (Field("Full Name") + ", " + Field("Credentials")).replace(/^,.+|, $/, '');

Link to comment
Share on other sites

The 11 point font would be selected in the text box and in this rule the point size for the credentials would be 9 point.

 

 

if ((Field("Full Name") != "") && (Field("Credentials") != ""))
return Field("Full Name") + ", " + '<span font="Arial" pointsize=9>' + Field("Credentials") + '</span>';
else if ((Field("Full Name") != "") && (Field("Credentials") == ""))
return Field("Full Name");
else
return ""; 

I do like this better from Step's example

 

var result = Field("Full Name");
if (result && Field("Credentials"))
 result += ", " + '<span font="Arial" pointsize=9>' + Field("Credentials") + '</span>';
return result;

Link to comment
Share on other sites

The 11 point font would be selected in the text box and in this rule the point size for the credentials would be 9 point.

 

 

if ((Field("Full Name") != "") && (Field("Credentials") != ""))
return Field("Full Name") + ", " + '<span font="Arial" pointsize=9>' + Field("Credentials") + '</span>';
else if ((Field("Full Name") != "") && (Field("Credentials") == ""))
return Field("Full Name");
else
return ""; 

I do like this better from Step's example

 

var result = Field("Full Name");
if (result && Field("Credentials"))
 result += ", " + '<span font="Arial" pointsize=9>' + Field("Credentials") + '</span>';
return result;

 

I used code from Step's example with the font size additions and now it returns

Full Name, <span font="Arial" pointsize=9>Credentials</span>

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