Doc Merge: Using Multiselect Conditionals within a Table

Hey everyone!

As someone who works in Sugar Support, I've noticed a few recurring questions about Doc Merge templates lately, so I wanted to share some insights and tips to help you get the most out of this fantastic feature.

What’s Doc Merge?
Doc Merge allows you to seamlessly integrate your CRM data into professional documents. Whether you’re generating proposals, contracts, or reports, it’s a valuable tool that can save you time and enhance your documents’ professionalism.

Scenario: Displaying Specific Information for Multiselect Items

The Issue:
Some of you have been trying to use conditionals like ‘and’ (&&) and ‘or’ (||) inside collections (tables) when working with multiselect items. Unfortunately, these conditionals won’t work as you might expect in this context.

The Resolution:
Instead of using those conditionals, you can use the includes syntax. This approach allows you to check if specific values are part of your multiselect items effectively.

Example in Action

Let’s say you’re using the stock dp_business_purpose field from the Leads module. Here’s how you can set it up:

  1. Set Up Your Table: Start by creating your table layout in your Doc Merge template.
  2. Use the includes Syntax: Instead of trying to apply ‘and’ or ‘or’, use something like:
    plaintext
    Copy code
    {if $dp_business_purpose includes 'Specific Value'}
    This will check if 'Specific Value' is included in the selected options.
  3. Final Touches: Once you have your data merged, consider adjusting the aesthetics—like removing table borders and making the last column thin—to give it a clean, professional look.

{if (dp_business_purpose.filter(item=>item.includes("Business Communications")).length>0)}Business Communications

{endif}

{if (dp_business_purpose.filter(item=>item.includes("Marketing Communications by company")).length>0)} Marketing Communications by company

{endif}

Wrap-Up

I hope these tips help clarify how to effectively use Doc Merge templates, especially with multiselect items. If you have any questions or need further assistance, feel free to ask! I’m here to help you navigate this and make your experience as smooth as possible.

Happy merging!