Jump to content

Simple rule not working


david.young

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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");

Link to comment
Share on other sites

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

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