Reputation: 1
Hi wonderful people of StackOverflow.
I've been scratching my head at the below Mailmerge formula code for an hour of so now and can't seem to figure out why it would be throw up an error. Is anyone with an eagle-eye able to point out any syntax errors or issues as to why the code wouldn't be working? I think it might be cause it's not registering the number values as true/false?
Essentially in this example, I want to check if the MergeField contains either reference to "Dyslexia" OR "ADHD" and if one or both is true display some text, in this case "yes".
ps. I built the code in the toggle code field editor so it's not copied or pasted.
Upvotes: 0
Views: 465
Reputation: 1301
FWIW Dyslexia;ADHD;Heart Murmer;
does not look like a valid data source field name to me. If it is, you should be able to plug it back into the code I suggest below, where I'm going to assume that the field you are testing is actually called Condition
.
You could then use something like
{IF{={IF {MERGEFIELD Condition} = "Dyslexia*" 1 0}+{IF {MERGEFIELD Condition} = "ADHD*" 1 0}} > 0 Yes No}
That will only match If either ADHD
or Dyslexia
is at the beginning of Condition, but there is no simple way to do a proper "contains" comparison using the "field language". It is also case sensitive, I.e. if you need to be able to detect adhd
etc. as well, you need something more like
{IF {MERGEFIELD Condition \*Upper} = "ADHD*" }
etc.
You can cut some more spaces out of that if you prefer but as usual all the {} must be the special field code brace pairs that you can enter on Windows Desktop Word using ctrl-F9.
(I'm not sitting at a suitable PC so cannot test my code, but that should point you in the right direction).
Upvotes: 0