david.young Posted December 10, 2015 Share Posted December 10, 2015 FP 9.3.21 Windows 7 Acrobat DC What should be simple has me perplexed, when this rule executes if there is no Business name the "and" shows. if (Field("Business") == "") { return Field("First Name"); } else { return Field("First Name") + ("and") + Field("Business") + Field("Name2"); } return ""; Thanks David Young Quote Link to comment Share on other sites More sharing options...
jwhittaker Posted December 10, 2015 Share Posted December 10, 2015 David I like to call the case where there is something in the field first so my code would look like this: if (Field("Business") != "") return Field("First Name") + "and" + Field("Business") + Field("Name2"); else return Field("First Name"); You don't need the () around the "and" You also had an extra return ""; at the end which isn't doing anything. Quote Link to comment Share on other sites More sharing options...
Dan Korn Posted December 10, 2015 Share Posted December 10, 2015 Are you sure that the field value is actually empty? Maybe there's a space in there. Check the data file carefully. If you have a text editor that can show whitespace characters, that would be helpful. If there is some stray space in that field, you could use the Trim function to remove it, like so: if (!Trim(Field("Business"))) return Field("First Name"); //else return Field("First Name") + " and " + Field("Business") + " " + Field("Name2"); Quote Link to comment Share on other sites More sharing options...
david.young Posted December 10, 2015 Author Share Posted December 10, 2015 jwhittaker and Dan thanks for your help got it sorted out. I shouldn't try to wrote code with no sleep. Dan your comment about a space in what appears to be an empty cell, that was one of my first thoughts, been burned by sloppy data several times. Notepad ++ is one of my favorite pieces of software for looking for problems like that Thanks again 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.