You need to sign in to do that
Don't have an account?

Mailmerge and {IF}
Has anyone been able to use the {IF} in Word's mailmerge to conditionally include text based on a value returned from Salesforce?
For example:
{ IF «OPPORTUNITY_NUM_SVCS_DEFINED» <> "1" "Some conditional text." " " }
The example from Microsoft shows:
{ IF {MERGEFIELD Country \* Caps } <> "United Kingdom" "We offer special rates on travel to the British Isles." " " }
{ IF {MERGEFIELD Country \* Caps } <> "United Kingdom" "We offer special rates on travel to the British Isles." " " }
Which I have successfully used before.
Thanks!
-Jake
Thanks so much for your prompt reply and the Print Anything suggestion - this looks like it might do the trick! I also signed up for a trial of Conga Merge, which is very slick and pretty cheap.
-Jake
Here's how I solved the problem.
Tag the data that want to base the condition on as a named bookmark (Insert | Bookmark). If you don't want to display that value, hide it using format, font, hidden. You can then refer to the bookmarked field in the merge condition. Here's a sample:
{ ·IF·booking_system·=·"OSC"·"OSC"·"IBIS"· \*·MERGEFORMAT··}¶
booking_system is a bookmark containing the salesforce data field.
Works like a charm.
Wow - that sounds like a really great solution, but I'm having trouble getting it to work with my situation. Here's the deal: I've got a field called PO_Number, and if it's blank, I'd like to suppress it instead of showing a bunch of underscores... however, if it's not blank I'd like to show the PO_Number.
So, I added the PO_Number field, associated it with a bookmark called PO, and then I tried the following IF field:
Code:
If the PO_Number is empty it displays "PO" instead of nothing.
Yes I did. But we don't use products and don't have your configuration so I could not test it locally. The way I tested was to add the logic to my template. I'm working with you because I expect to have to deliver the same requirement soon.
I would be willing to use GoToMeeting to resolve this.
Message Edited by Jakester on 11-16-2007 05:55 PM
Brian,
I am not a developer. Can you help me with some clear steps as to how to get rid of the Blanks when doing a mail merge?
I am trying to merge a salesforce <<account_name>> but don't want the ____ (blanks).
It looked like you solved the problem. But I don't even understand how to setup the book mark you are referring and what you mean by tagging the data.
Any help is greatly appreciated.
Luis
Luis,
Look at my earlier messages. I'd like to help you, but could you start with MS Word help on setting bookmarks? This is base Word functionality. You might also read up on Mail Merge in general. IF you still have issues after referring to these resources, I'll help.
Also, I'm BRAILM, not Brian. It took a while to figure out you addressed this to me.
Hi Brailm,
I tried mail merge with IF condition as you suggested using bookmark. Here is the line of code I have: -
{ IF.Spouse_Name.=."N/A"."No Spouse"."Spouse".}
Spouse_Name is a bookmark containing the salesforce data field - [MERGEFIELD ACCOUNT_SPOUSE_S_NAME].
When I generate the file, I get { IF.Spouse_Name.=."N/A"."No Spouse"."Spouse".} in the file. It is not executing the code.
Can you tell me if I am missing anything?
Thanks
Sunil
Message Edited by Sunil on 06-13-2008 06:11 AM
I "up" this topic because I'm working on Word document with mail merge but I don't understand how {IF} works.
I want to test the civility of a person to modify my document like this :
{if {mergefi... contact_salutation \* mergefi...}= "Mister""his""her")}
The result is an error like "the test condition isn't found".
Please, can you explain to me how use this function? Also you speak about "bookmark", can you detail more?
Thank you.
Damien.
If you have any exemple, I'm listening (reading :robothappy:).
Good luck for your project brailm.
Hi we've got a similar problem.
I put a named bookmark 'Salut2' into a word template and assigned the mergefield contact_salutation to it. Using a compare like compare Salut2 = Mr. delivers a 0 or 1 if Mr. is true. So far it seems to work.
Using the mix of IF and OR condition does not work. My code was:
{ IF { = OR ({ COMPARE Salut2 = Mr. } , { COMPARE Salut2 = Mrs. }) = 1 "do something" "do something else"}}.
Putting the bookmark into curly brackets did not work. Using a semicolon instead of a comma between the compares did not work either. More or less blanks in between did not work. What is the mistake I make?
The field contact_salutation is filled properly from salesforce. I also tried with contact_salutation as a mergefield in the compare. This did not succeed.
Do you have any idea on how to solve that? I would be very glad to get help around that.... Thanks in advance....
Cheers Thomas