Jump to content
Welcome to the new FusionPro User Forum! ×

Suppress text with in rule


oleooo

Recommended Posts

I am have no luck on suppressing fields in my rule. I turned on Suppress if containing empty variables. This did not work so I am a bit dumbfounded.

Is there a solution here or do I have it all wrong.

 

Here is the code I am working with

 

//this JavaScript will produce a string like of text to show address in frame

if (Field("Address 2") == "")

return "";

else

return '<f name=\"HelveticaNeueLT Pro 75 Bd\"><z newsize="8">'+Field("Department")+'<br>'+Field("Specialty")+'<br>'+'<f name=\"HelveticaNeueLT Pro 55 Roman\"><z newsize="7">'+Field("Address")+'<br>'+Field("POBOX")+'<br>'+Field("CityStateZip")+'<br>'+Rule("PhoneFormatRule")+' , '+Rule("FaxFormatRule")+'<br>'+Field("Dropdown")+Rule("NumberFormatRule")+'<br>'+'<br>'+'<f name=\"HelveticaNeueLT Pro 75 Bd\"><z newsize="8">'+Field("Practice Name 2")+'<br>'+Field("Department2")+'<br>'+'<f name=\"HelveticaNeueLT Pro 55 Roman\"><z newsize="7">'+Field("Address 2")+'<br>'+Field("PO Box")+'<br>'+Field("CityStateZip2")+'<br>'+Rule("PhoneFormatRule2")+'&absp;,&absp;'+Rule("FaxFormatRule2")+'<br>'+Field("email");

Link to comment
Share on other sites

If this is related to your other thread regarding formatting of addresses on a business card, I don't think the rule is your problem.

 

I assume you are using the rule above for the frame which contains two addresses and it only returns a value if two addresses are present in the data. If so, then that sounds correct.

 

For the second frame (the one that will contain only one address when only one is presented in the data), you will need a 2nd rule that returns nothing to its frame if Field("Address 2") DOES have a value, otherwise return tagged output for one address. So assuming your rule works in the one scenario, the alternate rule might look like:

if (Field("Address 2") == "")
return '<f name=\"HelveticaNeueLT Pro 75 Bd\"><z newsize="8">'+Field("Department")+'<br>'+Field("Sp ecialty")+'<br>'+'<f name=\"HelveticaNeueLT Pro 55 Roman\"><z newsize="7">'+Field("Address")+'<br>'+Field("POBOX ")+'<br>'+Field("CityStateZip")+'<br>'+Rule("Phone FormatRule")+' , '+Rule("FaxFormatRule") +'<br>'+Field("Dropdown")+Rule("NumberFormatRule");
else
return "";

Link to comment
Share on other sites

Eric,

 

The rule works, the problem is that if for instance Department is not selected

it leaves a space, but does not suppress or move up. I was unclear on this. I need to have the fields that have no info from the user to not leave a blank space but to move up to the closes line.

 

I hope I was clear

 

Thanks

Ole

Link to comment
Share on other sites

Replace all your instances of '<br>' in the rule with '<p skipifempty=true>'.

 

Or, don't use a rule at all; just enter everything into the Text Editor and set Suppress if Empty there. Frankly, I'm not sure why you're using a rule and tags in the first place; that seems unnecessarily complicated for what you're doing.

Link to comment
Share on other sites

Ah. In that case, you need to build your result with several IF statements to test the value of each field before adding it to the output:

// return a value for records with only one address
var result = "";
if (Field("Address 2") == "") {
  result += (Field("Department") != "") ? '<f name="HelveticaNeueLT Pro 75 Bd"><z newsize="8">' + Field("Department") : "";
  result += (Field("Specialty") != "") ? '<br>' + Field("Specialty") : "";
  result += (Field("Address") != "") ? '<br>' + '<f name="HelveticaNeueLT Pro 55 Roman"><z newsize="7">' + Field("Address") : "";
  result += (Field("POBOX ") != "") ? '<br>' + Field("POBOX ") : "";
  result += (Field("CityStateZip") != "") ? '<br>' + Field("CityStateZip") : "";
  result += (Field("Phone") != "") ? '<br>' + Rule("Phone FormatRule") + ' , ' + Rule("FaxFormatRule") : "";
  result += (Field("Dropdown") != "") ? '<br>' + Field("Dropdown") + Rule("NumberFormatRule") : "";
}
return result;

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