{"id":4198,"date":"2021-12-14T13:44:36","date_gmt":"2021-12-14T12:44:36","guid":{"rendered":"https:\/\/help.r2docuo.com\/knowledge-base\/conditional-if-macros-in-word-365-templates\/"},"modified":"2023-11-06T09:20:52","modified_gmt":"2023-11-06T08:20:52","slug":"conditional-if-macros-in-word-365-templates","status":"publish","type":"ht_kb","link":"https:\/\/help.r2docuo.com\/en\/knowledge-base\/conditional-if-macros-in-word-365-templates\/","title":{"rendered":"Conditional (IF) macros in Word 365 templates"},"content":{"rendered":"<p>This macro for Word 365 templates in Docuo allows you to establish a condition to determine whether or not the text fragment it contains will be included in the document.<\/p>\n<p>Formula macros in Word templates are only <strong>available in Docuo Enterprise.<\/strong><\/p>\n<p>The definition of the formula is done in the Word document itself with the following syntax:<\/p>\n<div style=\"padding: 1em; border: 1px dashed #2f6fab; color: black; background-color: #f9f9f9; line-height: 1.1em; font-size: 0.8em;\">\n<p><tt>@DOCUO.IF{\"condition\",[reemplazo \u00fanico]}<\/tt><\/p>\n<p><em>Word text fragment<\/em><\/p>\n<p><tt>@DOCUO.ENDIF{}<\/tt><\/p>\n<\/div>\n<p>Where:<\/p>\n<p><strong>Condition:<\/strong> Filter that allows you to specify <strong>with T-SQL syntax<\/strong> the conditions that must be met in this conditional. Remember to use the category code at the beginning of the tags you use and, if you type the quotation marks from Word, you must press Ctrl+z after typing them so that Word does not replace them with a stylized quotation mark. We recommend writing the macro in a plain text editor and pasting it into Word afterwards.<\/p>\n<p><b>Single replacement<\/b> : Optional parameter. If TRUE, the replacement occurs only once (the formula will not be recalculated each time labels are replaced). By default it is FALSE so that each time labels are replaced the data is automatically updated.<\/p>\n<p>In this example we use a conditional macro so that depending on the &#8220;Method of payment&#8221; of an invoice, a text fragment appears that contains the data to make the transfer:<\/p>\n<div style=\"padding: 1em; border: 1px dashed #2f6fab; color: black; background-color: #f9f9f9; line-height: 1.1em; font-size: 0.8em;\">\n<p>Invoice number:&lt; @Properties:Code&gt;<br \/>\nClient:&lt; @Customer:Name&gt;<br \/>\nAmount:&lt; @Data:Total&gt;<\/p>\n<p><tt>@DOCUO.IF{\"&lt;@FAC:Data:Payment method&gt;='Transfer'\"}<\/tt><\/p>\n<p>CONTOSO BANK S.A.<\/p>\n<p>IBAN: ES4202413226312852213980<\/p>\n<p>Due date:&lt; @Data:Expiration&gt;<\/p>\n<p><tt>@DOCUO.ENDIF{}<\/tt><\/p>\n<\/div>\n<p>As the UNIQUE REPLACEMENT parameter has been omitted, if the payment method changes, the condition will be evaluated again when labels are replaced from Docuo.<\/p>\n<p>Conditional macros can be nested and contain other macros. Following the previous example, we could show the payment account in a different way depending on whether our client is international or not:<\/p>\n<div style=\"padding: 1em; border: 1px dashed #2f6fab; color: black; background-color: #f9f9f9; line-height: 1.1em; font-size: 0.8em;\">\n<p>Invoice number:&lt; @Properties:Code&gt;<br \/>\nClient:&lt; @Customer:Name&gt;<br \/>\nAmount:&lt; @Data:Total&gt;<\/p>\n<p><tt>@DOCUO.IF{\"&lt;@FAC:Data:Payment method&gt;='Transfer'\"}<\/tt><\/p>\n<p>CONTOSO BANK S.A.<\/p>\n<p style=\"padding-left: 40px;\"><tt>@DOCUO.IF{\"&lt;@FAC:Client:Country&gt;='Spain'\"}<\/tt><\/p>\n<p style=\"padding-left: 40px;\">IBAN: ES4202413226312852213980<\/p>\n<p style=\"padding-left: 40px;\">Due date:&lt; @Data:Expiration&gt;<\/p>\n<p style=\"padding-left: 40px;\"><tt>@DOCUO.ENDIF{}<\/tt><\/p>\n<p style=\"padding-left: 40px;\"><tt>@DOCUO.IF{\"&lt;@FAC:Client:Country&gt;&lt;&gt;'Spain'\"}<\/tt><\/p>\n<p style=\"padding-left: 40px;\">SWIFT (BIC): CONT ES 1701 4202413226312852213980<\/p>\n<p style=\"padding-left: 40px;\">Due date:&lt; @Data:Expiration&gt;<\/p>\n<p style=\"padding-left: 40px;\"><tt>@DOCUO.ENDIF{}<\/tt><\/p>\n<p><tt>@DOCUO.ENDIF{}<\/tt><\/p>\n<\/div>\n<p>Conditional macros in Word templates allow you to create more advanced document templates <strong>without having to create different templates<\/strong> for different variations of your document.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This macro for Word 365 templates in Docuo allows you to establish a condition to determine whether or not the text fragment it contains will be included in the document. Formula macros in Word templates are only available in Docuo Enterprise. The definition of the formula is done in the&#8230;<\/p>\n","protected":false},"author":1,"comment_status":"open","ping_status":"closed","template":"","format":"standard","meta":{"content-type":"","footnotes":""},"ht-kb-category":[58],"ht-kb-tag":[83],"class_list":["post-4198","ht_kb","type-ht_kb","status-publish","format-standard","has-post-thumbnail","hentry","ht_kb_category-macros","ht_kb_tag-docuo-enterprise"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Conditional (IF) macros in Word 365 templates - R2 Docuo | Help center<\/title>\n<meta name=\"robots\" content=\"noindex, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Conditional (IF) macros in Word 365 templates - R2 Docuo | Help center\" \/>\n<meta property=\"og:description\" content=\"This macro for Word 365 templates in Docuo allows you to establish a condition to determine whether or not the text fragment it contains will be included in the document. Formula macros in Word templates are only available in Docuo Enterprise. The definition of the formula is done in the...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/help.r2docuo.com\/en\/knowledge-base\/conditional-if-macros-in-word-365-templates\/\" \/>\n<meta property=\"og:site_name\" content=\"R2 Docuo | Help center\" \/>\n<meta property=\"article:modified_time\" content=\"2023-11-06T08:20:52+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/help.r2docuo.com\/wp-content\/uploads\/2021\/03\/Post-type-Guias-de-usuario.png\" \/>\n\t<meta property=\"og:image:width\" content=\"845\" \/>\n\t<meta property=\"og:image:height\" content=\"564\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:site\" content=\"@R2Docuo\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/help.r2docuo.com\\\/en\\\/knowledge-base\\\/conditional-if-macros-in-word-365-templates\\\/\",\"url\":\"https:\\\/\\\/help.r2docuo.com\\\/en\\\/knowledge-base\\\/conditional-if-macros-in-word-365-templates\\\/\",\"name\":\"Conditional (IF) macros in Word 365 templates - R2 Docuo | Help center\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/help.r2docuo.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/help.r2docuo.com\\\/en\\\/knowledge-base\\\/conditional-if-macros-in-word-365-templates\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/help.r2docuo.com\\\/en\\\/knowledge-base\\\/conditional-if-macros-in-word-365-templates\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/help.r2docuo.com\\\/wp-content\\\/uploads\\\/2021\\\/03\\\/Post-type-Guias-de-usuario.png\",\"datePublished\":\"2021-12-14T12:44:36+00:00\",\"dateModified\":\"2023-11-06T08:20:52+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/help.r2docuo.com\\\/en\\\/knowledge-base\\\/conditional-if-macros-in-word-365-templates\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/help.r2docuo.com\\\/en\\\/knowledge-base\\\/conditional-if-macros-in-word-365-templates\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/help.r2docuo.com\\\/en\\\/knowledge-base\\\/conditional-if-macros-in-word-365-templates\\\/#primaryimage\",\"url\":\"https:\\\/\\\/help.r2docuo.com\\\/wp-content\\\/uploads\\\/2021\\\/03\\\/Post-type-Guias-de-usuario.png\",\"contentUrl\":\"https:\\\/\\\/help.r2docuo.com\\\/wp-content\\\/uploads\\\/2021\\\/03\\\/Post-type-Guias-de-usuario.png\",\"width\":845,\"height\":564},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/help.r2docuo.com\\\/en\\\/knowledge-base\\\/conditional-if-macros-in-word-365-templates\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Portada\",\"item\":\"https:\\\/\\\/help.r2docuo.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Conditional (IF) macros in Word 365 templates\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/help.r2docuo.com\\\/#website\",\"url\":\"https:\\\/\\\/help.r2docuo.com\\\/\",\"name\":\"R2 Docuo | Help center\",\"description\":\"Todos los recursos para usuarios, administradores y desarrolladores de de R2 Docuo a tu alcance\",\"publisher\":{\"@id\":\"https:\\\/\\\/help.r2docuo.com\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/help.r2docuo.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/help.r2docuo.com\\\/#organization\",\"name\":\"R2 Docuo | Help center\",\"url\":\"https:\\\/\\\/help.r2docuo.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/help.r2docuo.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/help.r2docuo.com\\\/wp-content\\\/uploads\\\/2023\\\/06\\\/ILUDEST_CENTRODEAYUDA.png\",\"contentUrl\":\"https:\\\/\\\/help.r2docuo.com\\\/wp-content\\\/uploads\\\/2023\\\/06\\\/ILUDEST_CENTRODEAYUDA.png\",\"width\":1200,\"height\":630,\"caption\":\"R2 Docuo | Help center\"},\"image\":{\"@id\":\"https:\\\/\\\/help.r2docuo.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/x.com\\\/R2Docuo\",\"https:\\\/\\\/www.linkedin.com\\\/company\\\/r2docuo\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Conditional (IF) macros in Word 365 templates - R2 Docuo | Help center","robots":{"index":"noindex","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"og_locale":"en_US","og_type":"article","og_title":"Conditional (IF) macros in Word 365 templates - R2 Docuo | Help center","og_description":"This macro for Word 365 templates in Docuo allows you to establish a condition to determine whether or not the text fragment it contains will be included in the document. Formula macros in Word templates are only available in Docuo Enterprise. The definition of the formula is done in the...","og_url":"https:\/\/help.r2docuo.com\/en\/knowledge-base\/conditional-if-macros-in-word-365-templates\/","og_site_name":"R2 Docuo | Help center","article_modified_time":"2023-11-06T08:20:52+00:00","og_image":[{"width":845,"height":564,"url":"https:\/\/help.r2docuo.com\/wp-content\/uploads\/2021\/03\/Post-type-Guias-de-usuario.png","type":"image\/png"}],"twitter_card":"summary_large_image","twitter_site":"@R2Docuo","twitter_misc":{"Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/help.r2docuo.com\/en\/knowledge-base\/conditional-if-macros-in-word-365-templates\/","url":"https:\/\/help.r2docuo.com\/en\/knowledge-base\/conditional-if-macros-in-word-365-templates\/","name":"Conditional (IF) macros in Word 365 templates - R2 Docuo | Help center","isPartOf":{"@id":"https:\/\/help.r2docuo.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/help.r2docuo.com\/en\/knowledge-base\/conditional-if-macros-in-word-365-templates\/#primaryimage"},"image":{"@id":"https:\/\/help.r2docuo.com\/en\/knowledge-base\/conditional-if-macros-in-word-365-templates\/#primaryimage"},"thumbnailUrl":"https:\/\/help.r2docuo.com\/wp-content\/uploads\/2021\/03\/Post-type-Guias-de-usuario.png","datePublished":"2021-12-14T12:44:36+00:00","dateModified":"2023-11-06T08:20:52+00:00","breadcrumb":{"@id":"https:\/\/help.r2docuo.com\/en\/knowledge-base\/conditional-if-macros-in-word-365-templates\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/help.r2docuo.com\/en\/knowledge-base\/conditional-if-macros-in-word-365-templates\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/help.r2docuo.com\/en\/knowledge-base\/conditional-if-macros-in-word-365-templates\/#primaryimage","url":"https:\/\/help.r2docuo.com\/wp-content\/uploads\/2021\/03\/Post-type-Guias-de-usuario.png","contentUrl":"https:\/\/help.r2docuo.com\/wp-content\/uploads\/2021\/03\/Post-type-Guias-de-usuario.png","width":845,"height":564},{"@type":"BreadcrumbList","@id":"https:\/\/help.r2docuo.com\/en\/knowledge-base\/conditional-if-macros-in-word-365-templates\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Portada","item":"https:\/\/help.r2docuo.com\/"},{"@type":"ListItem","position":2,"name":"Conditional (IF) macros in Word 365 templates"}]},{"@type":"WebSite","@id":"https:\/\/help.r2docuo.com\/#website","url":"https:\/\/help.r2docuo.com\/","name":"R2 Docuo | Help center","description":"Todos los recursos para usuarios, administradores y desarrolladores de de R2 Docuo a tu alcance","publisher":{"@id":"https:\/\/help.r2docuo.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/help.r2docuo.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/help.r2docuo.com\/#organization","name":"R2 Docuo | Help center","url":"https:\/\/help.r2docuo.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/help.r2docuo.com\/#\/schema\/logo\/image\/","url":"https:\/\/help.r2docuo.com\/wp-content\/uploads\/2023\/06\/ILUDEST_CENTRODEAYUDA.png","contentUrl":"https:\/\/help.r2docuo.com\/wp-content\/uploads\/2023\/06\/ILUDEST_CENTRODEAYUDA.png","width":1200,"height":630,"caption":"R2 Docuo | Help center"},"image":{"@id":"https:\/\/help.r2docuo.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/x.com\/R2Docuo","https:\/\/www.linkedin.com\/company\/r2docuo"]}]}},"_links":{"self":[{"href":"https:\/\/help.r2docuo.com\/en\/wp-json\/wp\/v2\/ht-kb\/4198","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/help.r2docuo.com\/en\/wp-json\/wp\/v2\/ht-kb"}],"about":[{"href":"https:\/\/help.r2docuo.com\/en\/wp-json\/wp\/v2\/types\/ht_kb"}],"author":[{"embeddable":true,"href":"https:\/\/help.r2docuo.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/help.r2docuo.com\/en\/wp-json\/wp\/v2\/comments?post=4198"}],"version-history":[{"count":0,"href":"https:\/\/help.r2docuo.com\/en\/wp-json\/wp\/v2\/ht-kb\/4198\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/help.r2docuo.com\/en\/wp-json\/wp\/v2\/media\/4053"}],"wp:attachment":[{"href":"https:\/\/help.r2docuo.com\/en\/wp-json\/wp\/v2\/media?parent=4198"}],"wp:term":[{"taxonomy":"ht_kb_category","embeddable":true,"href":"https:\/\/help.r2docuo.com\/en\/wp-json\/wp\/v2\/ht-kb-category?post=4198"},{"taxonomy":"ht_kb_tag","embeddable":true,"href":"https:\/\/help.r2docuo.com\/en\/wp-json\/wp\/v2\/ht-kb-tag?post=4198"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}