oleooo Posted September 22, 2011 Share Posted September 22, 2011 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"); Quote Link to comment Share on other sites More sharing options...
esmith Posted September 22, 2011 Share Posted September 22, 2011 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 ""; Quote Link to comment Share on other sites More sharing options...
oleooo Posted September 22, 2011 Author Share Posted September 22, 2011 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 Quote Link to comment Share on other sites More sharing options...
Dan Korn Posted September 22, 2011 Share Posted September 22, 2011 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. Quote Link to comment Share on other sites More sharing options...
oleooo Posted September 22, 2011 Author Share Posted September 22, 2011 Dan, Thanks again I will get it one of these days. You guys Rock! Thanks Ole Quote Link to comment Share on other sites More sharing options...
esmith Posted September 22, 2011 Share Posted September 22, 2011 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; Quote Link to comment Share on other sites More sharing options...
esmith Posted September 22, 2011 Share Posted September 22, 2011 Replace all your instances of '<br>' in the rule with '<p skipifempty=true>'. One of these days, Alice... Quote Link to comment Share on other sites More sharing options...
oleooo Posted September 22, 2011 Author Share Posted September 22, 2011 Eric, Wow, That Is very cool. Thanks for the help You rock. Ole Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.