Writer: Hiding a paragraph based upon multiple variables

We have a standard letter that we send to new clients. Some of the information in that letter changes depending on whether they are currently in jail or out on bond. Previously, we had a user variable (called “BondOrJail”) that we used to define which text was shown. It worked great!

We have now started capturing that information (whether they are out on bond or in jail) in our database and want to use that information to trigger the change in text. Because some of our records pre-date the expansion of the database, we want the option of being able to trigger it by EITHER the database variable (database.casedetails.BondStatus) or the user variable (“BondOrJail”). I got it to work with “conditional text” by using this formula:

((BondOrJail == “Jail”) or (BondOrJail == “JAIL”) or (database.casedetails.BondStatus == “JAIL”) or (database.casedetails.BondStatus == “Jail”))

If the condition is “TRUE”, then it prints the word “Jail”. If none of the variables meet the criteria, then it prints the word “Bond”. It works swimmingly.

Several paragraphs need to be hidden in the client is not in jail, and for those I used this formula:

((BondOrJail != “Jail”) and (BondOrJail != “JAIL”)) and ((database.casedetails.BondStatus != “JAIL”) and (database.casedetails.BondStatus != “Jail”))

This SHOULD make the paragraph disappear entirely if none of the values has “JAIL” or “Jail”. (The variations are needed because not everyone has been consistent in their capitalization…) It does not work; instead, the paragraph only disappears based upon the “BondOrJail” value, and not the database value. (So if “BondOrJail” equals “Jail”, it disappears, even if “database.casedetails.BondStatus” equals “Jail”.)

It works if I do it as:

((BondOrJail != “Jail”) and (BondOrJail != “JAIL”))

And it works if I do it as:

((database.casedetails.BondStatus != “JAIL”) and (database.casedetails.BondStatus != “Jail”))

But if I use both, it doesn’t work.

I’ve tried without the outside parentheticals. I’ve tried with the whole thing in parentheticals. I’ve tried every variation I can think of. What am I doing wrong here?

(This is in LibO 7.0, Win 10 64 bit.)

Don’t know if this is relevant. Your first formula is ( () or () or () or () ) while the second is ( () and () ) and ( () and () ) which is 2 terms bound by and instead of a single term. Have you tried ( () and () and () and () ) ?

I have tried it without any of the external parentheticals, with the same result.

(I should have specified in the original post that the goal is for the text to appear if any of the variables equals “Jail” or “JAIL”, but what’s it seems to be doing is ignoring the variable from the database entirely. Edited the original question to reflect this.)

What’s weird is that when I set the database value to “JAIL” or “Jail”, the paragraphs will appear briefly, and then disappear again.

I also tried reversing the variables (i.e., changing the order of operations to evaluate “database.casedetails.BondStatus” before evaluating “BondOrJail”), and I get the opposite result of what I experienced earlier: it changes depending on the database values and not the user-variable values. Basically, it seems to be ignoring the values of whichever set of variables comes last.

It looks like “inner” parentheses are needed as in () and () and () and (). I have no database to test, so I did this only with variables. I kind of remember that DB variables may be enclosed in square brackets like [database.casedetails.status] == …. I write “may” because it should not matter.

I think the brackets for the database are only necessary if the database has spaces or a special character (like a “-”) in the name. I actually do have my database path in brackets because the actual database name has spaces and a dash in it; I just left the brackets out on the explanation for the sake of readability.

I can get it work with just the inner parenthesis if I just use database variables, or if I just use user variables, but not if I use both. It’s so weird; for conditional text using “OR” and “==” it works fine, but when I switch to “AND” and “!=” it flips out.

Then try your original formula as not (). It’ll give the same result as the complemented expression using De Morgan’s law as you did.