Skip to content Skip to main navigation Skip to footer

Conditional logic to generate different versions of the same template

We have several versions of the same template, one for a loan agreement and one for a lease agreement.  We would like to merge this into one template but use conditional logic to populate the appropriate details (e.g. there may be a field that should say “Loan Agreement” if the product is a loan but would then say “Lease Agreement” if the product is a lease).  In my past experience I have used “If / Then” coding to do this.  Does Opero Documents allow for this?  

Yes, you can conditionally merge sections onto a template.  We advise to create a formula field that is a checkbox that can check the box on one condition or leave unchecked if another condition.  Then in the template builder you would use this field to create a conditional merge section. The app generates merge code that you copy/paste at the beginning of the section and end of the section.

Another option around this type of concept is to create a formula that can provide text for the title of the agreement based on specific conditions. For example, in the formula field you would have whatever logic you need to display “Loan Agreement” or “Lease Agreement” text, and merge this field as the title of the document.  This could be a good strategy if there are only a few things that are different.  For large sections of text, conditional merge would make more sense.

If you would prefer to have two templates, you can include an if statement in your custom button code that decides which Document Action to use for the document based on some field value. Or, create a record-triggered Flow with a decision element that checks the value of a specific field and creates a Document Request Record with a Document Action that corresponds with the value of the field. For example, if the field equals “Loan agreement”, create a Document Request with Document Action set to GDT-000001 and if the field equals “Lease Agreement”, create a Document Request with Document Action set to GDT-000002. See Automate Document Generation article for more details.