{"id":4194,"date":"2021-12-21T09:14:17","date_gmt":"2021-12-21T08:14:17","guid":{"rendered":"https:\/\/help.r2docuo.com\/knowledge-base\/control-by-js-formula-to-advance-and-undo-transitions\/"},"modified":"2023-11-06T09:20:51","modified_gmt":"2023-11-06T08:20:51","slug":"control-by-js-formula-to-advance-and-undo-transitions","status":"publish","type":"ht_kb","link":"https:\/\/help.r2docuo.com\/en\/knowledge-base\/control-by-js-formula-to-advance-and-undo-transitions\/","title":{"rendered":"JavaScript formula control to advance and undo transitions"},"content":{"rendered":"<p>The category manager <strong>control<\/strong> step allows us to set restrictions to <strong>control who and when can advance or roll back through any transition<\/strong> in a process.<\/p>\n<p>Firstly, you can set which users can or can&#8217;t move forward\/back through the transition.<\/p>\n<p>At a more advanced level, it is also possible to specify a <strong>JavaScript formula<\/strong> that, based on its result, causes the control to take effect or not.<\/p>\n<p><strong>The formula must be designed to return a message or reason why the action is prevented from the user<\/strong> . If the formula does not return a message (it returns the empty message &#8220;&#8221;) it is understood that this control has no effect.<\/p>\n<p>For example, if in a category of Invoices we want that from a certain amount only a supervisor can issue it (advance from creation to issue) we could put a control like:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-3943 size-full\" src=\"https:\/\/helpr2docuo.wpengine.com\/wp-content\/uploads\/2021\/12\/Control.png\" alt=\"\" width=\"986\" height=\"624\" srcset=\"https:\/\/help.r2docuo.com\/wp-content\/uploads\/2021\/12\/Control.png 986w, https:\/\/help.r2docuo.com\/wp-content\/uploads\/2021\/12\/Control-300x190.png 300w, https:\/\/help.r2docuo.com\/wp-content\/uploads\/2021\/12\/Control-768x486.png 768w, https:\/\/help.r2docuo.com\/wp-content\/uploads\/2021\/12\/Control-50x32.png 50w, https:\/\/help.r2docuo.com\/wp-content\/uploads\/2021\/12\/Control-60x38.png 60w, https:\/\/help.r2docuo.com\/wp-content\/uploads\/2021\/12\/Control-100x63.png 100w\" sizes=\"auto, (max-width: 986px) 100vw, 986px\" \/><\/p>\n<p>This formula could have the following code:<\/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>if(&lt; @Data:Total&gt;&gt; 3000 &amp;&amp;<br \/>\n&lt;@Data:Supervisors&gt; .indexOf(User.name())&lt; 0)<\/tt><\/p>\n<p>return &#8220;This invoice can only be issued by a supervisor&#8221;<\/p>\n<p>else<\/p>\n<p><tt> return \"\"<\/tt><\/p>\n<\/div>\n<p>In this way, if the value of the &#8220;Total&#8221; field is greater than 3,000 and the name of the advancing user is not in the &#8220;Supervisors&#8221; user type field, <strong>the corresponding error message will be displayed<\/strong> . In any other case, returning an empty string overrides this check and the transition can be used by anyone.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The category manager control step allows us to set restrictions to control who and when can advance or roll back through any transition in a process. Firstly, you can set which users can or can&#8217;t move forward\/back through the transition. At a more advanced level, it is also possible to&#8230;<\/p>\n","protected":false},"author":1,"comment_status":"open","ping_status":"closed","template":"","format":"standard","meta":{"content-type":"","footnotes":""},"ht-kb-category":[64],"ht-kb-tag":[],"class_list":["post-4194","ht_kb","type-ht_kb","status-publish","format-standard","has-post-thumbnail","hentry","ht_kb_category-control"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>JavaScript formula control to advance and undo transitions - 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=\"JavaScript formula control to advance and undo transitions - R2 Docuo | Help center\" \/>\n<meta property=\"og:description\" content=\"The category manager control step allows us to set restrictions to control who and when can advance or roll back through any transition in a process. Firstly, you can set which users can or can&#8217;t move forward\/back through the transition. At a more advanced level, it is also possible to...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/help.r2docuo.com\/en\/knowledge-base\/control-by-js-formula-to-advance-and-undo-transitions\/\" \/>\n<meta property=\"og:site_name\" content=\"R2 Docuo | Help center\" \/>\n<meta property=\"article:modified_time\" content=\"2023-11-06T08:20:51+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=\"1 minute\" \/>\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\\\/control-by-js-formula-to-advance-and-undo-transitions\\\/\",\"url\":\"https:\\\/\\\/help.r2docuo.com\\\/en\\\/knowledge-base\\\/control-by-js-formula-to-advance-and-undo-transitions\\\/\",\"name\":\"JavaScript formula control to advance and undo transitions - R2 Docuo | Help center\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/help.r2docuo.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/help.r2docuo.com\\\/en\\\/knowledge-base\\\/control-by-js-formula-to-advance-and-undo-transitions\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/help.r2docuo.com\\\/en\\\/knowledge-base\\\/control-by-js-formula-to-advance-and-undo-transitions\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/help.r2docuo.com\\\/wp-content\\\/uploads\\\/2021\\\/03\\\/Post-type-Guias-de-usuario.png\",\"datePublished\":\"2021-12-21T08:14:17+00:00\",\"dateModified\":\"2023-11-06T08:20:51+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/help.r2docuo.com\\\/en\\\/knowledge-base\\\/control-by-js-formula-to-advance-and-undo-transitions\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/help.r2docuo.com\\\/en\\\/knowledge-base\\\/control-by-js-formula-to-advance-and-undo-transitions\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/help.r2docuo.com\\\/en\\\/knowledge-base\\\/control-by-js-formula-to-advance-and-undo-transitions\\\/#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\\\/control-by-js-formula-to-advance-and-undo-transitions\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Portada\",\"item\":\"https:\\\/\\\/help.r2docuo.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"JavaScript formula control to advance and undo transitions\"}]},{\"@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":"JavaScript formula control to advance and undo transitions - 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":"JavaScript formula control to advance and undo transitions - R2 Docuo | Help center","og_description":"The category manager control step allows us to set restrictions to control who and when can advance or roll back through any transition in a process. Firstly, you can set which users can or can&#8217;t move forward\/back through the transition. At a more advanced level, it is also possible to...","og_url":"https:\/\/help.r2docuo.com\/en\/knowledge-base\/control-by-js-formula-to-advance-and-undo-transitions\/","og_site_name":"R2 Docuo | Help center","article_modified_time":"2023-11-06T08:20:51+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":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/help.r2docuo.com\/en\/knowledge-base\/control-by-js-formula-to-advance-and-undo-transitions\/","url":"https:\/\/help.r2docuo.com\/en\/knowledge-base\/control-by-js-formula-to-advance-and-undo-transitions\/","name":"JavaScript formula control to advance and undo transitions - R2 Docuo | Help center","isPartOf":{"@id":"https:\/\/help.r2docuo.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/help.r2docuo.com\/en\/knowledge-base\/control-by-js-formula-to-advance-and-undo-transitions\/#primaryimage"},"image":{"@id":"https:\/\/help.r2docuo.com\/en\/knowledge-base\/control-by-js-formula-to-advance-and-undo-transitions\/#primaryimage"},"thumbnailUrl":"https:\/\/help.r2docuo.com\/wp-content\/uploads\/2021\/03\/Post-type-Guias-de-usuario.png","datePublished":"2021-12-21T08:14:17+00:00","dateModified":"2023-11-06T08:20:51+00:00","breadcrumb":{"@id":"https:\/\/help.r2docuo.com\/en\/knowledge-base\/control-by-js-formula-to-advance-and-undo-transitions\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/help.r2docuo.com\/en\/knowledge-base\/control-by-js-formula-to-advance-and-undo-transitions\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/help.r2docuo.com\/en\/knowledge-base\/control-by-js-formula-to-advance-and-undo-transitions\/#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\/control-by-js-formula-to-advance-and-undo-transitions\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Portada","item":"https:\/\/help.r2docuo.com\/"},{"@type":"ListItem","position":2,"name":"JavaScript formula control to advance and undo transitions"}]},{"@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\/4194","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=4194"}],"version-history":[{"count":0,"href":"https:\/\/help.r2docuo.com\/en\/wp-json\/wp\/v2\/ht-kb\/4194\/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=4194"}],"wp:term":[{"taxonomy":"ht_kb_category","embeddable":true,"href":"https:\/\/help.r2docuo.com\/en\/wp-json\/wp\/v2\/ht-kb-category?post=4194"},{"taxonomy":"ht_kb_tag","embeddable":true,"href":"https:\/\/help.r2docuo.com\/en\/wp-json\/wp\/v2\/ht-kb-tag?post=4194"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}