{"id":5103,"date":"2023-12-18T19:00:06","date_gmt":"2023-12-18T18:00:06","guid":{"rendered":"https:\/\/help.r2docuo.com\/knowledge-base\/how-to-run-a-script-when-you-change-the-value-of-a-field-in-the-edit-screen\/"},"modified":"2023-12-19T17:00:03","modified_gmt":"2023-12-19T16:00:03","slug":"how-to-run-a-script-when-you-change-the-value-of-a-field-in-the-edit-screen","status":"publish","type":"ht_kb","link":"https:\/\/help.r2docuo.com\/en\/knowledge-base\/how-to-run-a-script-when-you-change-the-value-of-a-field-in-the-edit-screen\/","title":{"rendered":"How to run a script when you change the value of a field in the edit screen"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Users enter or modify the value of data fields in Docuo from the details window of a document, or from web forms.<\/p>\n\n<p class=\"wp-block-paragraph\">To facilitate data entry, when a field is created, the type of content it will have is configured: Date, number, currency, text, drop-down lists, etc.<\/p>\n\n<p class=\"wp-block-paragraph\">However, sometimes, it is necessary to carry out a stricter control of what users can enter in a field.<\/p>\n\n<h2 class=\"wp-block-heading\">Restricting the format of a field by means of a regular expression<\/h2>\n\n<p class=\"wp-block-paragraph\">A first option is to set a Format, a strict restriction on what a user can enter, configured from what are known as <em>regular expressions<\/em>.<\/p>\n\n<p class=\"wp-block-ht-blocks-messages wp-block-hb-message wp-block-hb-message--withicon\">A regular expression is a sequence of characters that allows to detect a certain input pattern in a text. Information on how to define regular expressions to validate text can be found at <a href=\"http:\/\/www.regular-expressions.info\/\" target=\"_blank\" rel=\"noreferrer noopener\">http:\/\/www.regular-expressions.info\/<\/a>. <\/p>\n\n<p class=\"wp-block-paragraph\">Use the &#8220;Behavior &#8211; Format&#8221; option to set up a regular expression in a field to validate what the user enters:<\/p>\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"727\" height=\"533\" src=\"https:\/\/help.r2docuo.com\/wp-content\/uploads\/2023\/12\/image-31.png\" alt=\"\" class=\"wp-image-5097\" srcset=\"https:\/\/help.r2docuo.com\/wp-content\/uploads\/2023\/12\/image-31.png 727w, https:\/\/help.r2docuo.com\/wp-content\/uploads\/2023\/12\/image-31-600x440.png 600w, https:\/\/help.r2docuo.com\/wp-content\/uploads\/2023\/12\/image-31-50x37.png 50w, https:\/\/help.r2docuo.com\/wp-content\/uploads\/2023\/12\/image-31-60x44.png 60w, https:\/\/help.r2docuo.com\/wp-content\/uploads\/2023\/12\/image-31-100x73.png 100w\" sizes=\"auto, (max-width: 727px) 100vw, 727px\" \/><\/figure>\n\n<p class=\"wp-block-paragraph\">However, in some scenarios, rather than restricting what the user enters, what needs to be done is to analyze and modify it, either in the same field or in other fields.<\/p>\n\n<h2 class=\"wp-block-heading\">Execute a Script when a user changes the value of a field<\/h2>\n\n<p class=\"wp-block-paragraph\">The event &#8220;When changing the value&#8221; of the options of a data field, allows to write a code fragment in JavaScript language, which will be executed in the editing screen (details window or form) when the user types the text and validates it, typically by leaving the focus of the control (by pressing the tab key for example or clicking elsewhere with the mouse).<\/p>\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"649\" height=\"493\" src=\"https:\/\/help.r2docuo.com\/wp-content\/uploads\/2023\/12\/image-32.png\" alt=\"\" class=\"wp-image-5099\" srcset=\"https:\/\/help.r2docuo.com\/wp-content\/uploads\/2023\/12\/image-32.png 649w, https:\/\/help.r2docuo.com\/wp-content\/uploads\/2023\/12\/image-32-600x456.png 600w, https:\/\/help.r2docuo.com\/wp-content\/uploads\/2023\/12\/image-32-50x38.png 50w, https:\/\/help.r2docuo.com\/wp-content\/uploads\/2023\/12\/image-32-60x46.png 60w, https:\/\/help.r2docuo.com\/wp-content\/uploads\/2023\/12\/image-32-100x76.png 100w\" sizes=\"auto, (max-width: 649px) 100vw, 649px\" \/><\/figure>\n\n<p class=\"wp-block-paragraph\">The JavaScript code you write here can use proprietary functions such as <em>uiSetFieldValue<\/em>, which allow you to MODIFY the contents of the field you are typing in, or even other fields:<\/p>\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/help.r2docuo.com\/wp-content\/uploads\/2023\/12\/image-33.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1010\" height=\"493\" src=\"https:\/\/help.r2docuo.com\/wp-content\/uploads\/2023\/12\/image-33.png\" alt=\"\" class=\"wp-image-5101\" srcset=\"https:\/\/help.r2docuo.com\/wp-content\/uploads\/2023\/12\/image-33.png 1010w, https:\/\/help.r2docuo.com\/wp-content\/uploads\/2023\/12\/image-33-600x293.png 600w, https:\/\/help.r2docuo.com\/wp-content\/uploads\/2023\/12\/image-33-768x375.png 768w, https:\/\/help.r2docuo.com\/wp-content\/uploads\/2023\/12\/image-33-50x24.png 50w, https:\/\/help.r2docuo.com\/wp-content\/uploads\/2023\/12\/image-33-60x29.png 60w, https:\/\/help.r2docuo.com\/wp-content\/uploads\/2023\/12\/image-33-100x49.png 100w\" sizes=\"auto, (max-width: 1010px) 100vw, 1010px\" \/><\/a><\/figure>\n\n<p class=\"wp-block-paragraph\">This allows, for example, setting the first letter to uppercase when the user enters a proper name, parsing, splitting and separating the entered information and taking it to different fields, or simply validating the composition of what the user types with JavaScript and returning an explanatory error message.<\/p>\n\n<p class=\"wp-block-ht-blocks-messages wp-block-hb-message wp-block-hb-message--withicon is-style-info\">Scripts entered in this event are limited to acting on the document window itself, they cannot perform functions that require calculations on the Docuo server or on other documents and categories.<\/p>\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Users enter or modify the value of data fields in Docuo from the details window of a document, or from web forms. To facilitate data entry, when a field is created, the type of content it will have is configured: Date, number, currency, text, drop-down lists, etc. However, sometimes, it&#8230;<\/p>\n","protected":false},"author":1,"comment_status":"open","ping_status":"closed","template":"","format":"standard","meta":{"content-type":"","footnotes":""},"ht-kb-category":[63],"ht-kb-tag":[83],"class_list":["post-5103","ht_kb","type-ht_kb","status-publish","format-standard","hentry","ht_kb_category-fields","ht_kb_tag-docuo-enterprise"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to run a script when you change the value of a field in the edit screen - 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=\"How to run a script when you change the value of a field in the edit screen - R2 Docuo | Help center\" \/>\n<meta property=\"og:description\" content=\"Users enter or modify the value of data fields in Docuo from the details window of a document, or from web forms. To facilitate data entry, when a field is created, the type of content it will have is configured: Date, number, currency, text, drop-down lists, etc. However, sometimes, it...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/help.r2docuo.com\/en\/knowledge-base\/how-to-run-a-script-when-you-change-the-value-of-a-field-in-the-edit-screen\/\" \/>\n<meta property=\"og:site_name\" content=\"R2 Docuo | Help center\" \/>\n<meta property=\"article:modified_time\" content=\"2023-12-19T16:00:03+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/help.r2docuo.com\/wp-content\/uploads\/2023\/12\/image-31.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\\\/how-to-run-a-script-when-you-change-the-value-of-a-field-in-the-edit-screen\\\/\",\"url\":\"https:\\\/\\\/help.r2docuo.com\\\/en\\\/knowledge-base\\\/how-to-run-a-script-when-you-change-the-value-of-a-field-in-the-edit-screen\\\/\",\"name\":\"How to run a script when you change the value of a field in the edit screen - R2 Docuo | Help center\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/help.r2docuo.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/help.r2docuo.com\\\/en\\\/knowledge-base\\\/how-to-run-a-script-when-you-change-the-value-of-a-field-in-the-edit-screen\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/help.r2docuo.com\\\/en\\\/knowledge-base\\\/how-to-run-a-script-when-you-change-the-value-of-a-field-in-the-edit-screen\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/help.r2docuo.com\\\/wp-content\\\/uploads\\\/2023\\\/12\\\/image-31.png\",\"datePublished\":\"2023-12-18T18:00:06+00:00\",\"dateModified\":\"2023-12-19T16:00:03+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/help.r2docuo.com\\\/en\\\/knowledge-base\\\/how-to-run-a-script-when-you-change-the-value-of-a-field-in-the-edit-screen\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/help.r2docuo.com\\\/en\\\/knowledge-base\\\/how-to-run-a-script-when-you-change-the-value-of-a-field-in-the-edit-screen\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/help.r2docuo.com\\\/en\\\/knowledge-base\\\/how-to-run-a-script-when-you-change-the-value-of-a-field-in-the-edit-screen\\\/#primaryimage\",\"url\":\"https:\\\/\\\/help.r2docuo.com\\\/wp-content\\\/uploads\\\/2023\\\/12\\\/image-31.png\",\"contentUrl\":\"https:\\\/\\\/help.r2docuo.com\\\/wp-content\\\/uploads\\\/2023\\\/12\\\/image-31.png\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/help.r2docuo.com\\\/en\\\/knowledge-base\\\/how-to-run-a-script-when-you-change-the-value-of-a-field-in-the-edit-screen\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Portada\",\"item\":\"https:\\\/\\\/help.r2docuo.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to run a script when you change the value of a field in the edit screen\"}]},{\"@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":"How to run a script when you change the value of a field in the edit screen - 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":"How to run a script when you change the value of a field in the edit screen - R2 Docuo | Help center","og_description":"Users enter or modify the value of data fields in Docuo from the details window of a document, or from web forms. To facilitate data entry, when a field is created, the type of content it will have is configured: Date, number, currency, text, drop-down lists, etc. However, sometimes, it...","og_url":"https:\/\/help.r2docuo.com\/en\/knowledge-base\/how-to-run-a-script-when-you-change-the-value-of-a-field-in-the-edit-screen\/","og_site_name":"R2 Docuo | Help center","article_modified_time":"2023-12-19T16:00:03+00:00","og_image":[{"url":"https:\/\/help.r2docuo.com\/wp-content\/uploads\/2023\/12\/image-31.png","type":"","width":"","height":""}],"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\/how-to-run-a-script-when-you-change-the-value-of-a-field-in-the-edit-screen\/","url":"https:\/\/help.r2docuo.com\/en\/knowledge-base\/how-to-run-a-script-when-you-change-the-value-of-a-field-in-the-edit-screen\/","name":"How to run a script when you change the value of a field in the edit screen - R2 Docuo | Help center","isPartOf":{"@id":"https:\/\/help.r2docuo.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/help.r2docuo.com\/en\/knowledge-base\/how-to-run-a-script-when-you-change-the-value-of-a-field-in-the-edit-screen\/#primaryimage"},"image":{"@id":"https:\/\/help.r2docuo.com\/en\/knowledge-base\/how-to-run-a-script-when-you-change-the-value-of-a-field-in-the-edit-screen\/#primaryimage"},"thumbnailUrl":"https:\/\/help.r2docuo.com\/wp-content\/uploads\/2023\/12\/image-31.png","datePublished":"2023-12-18T18:00:06+00:00","dateModified":"2023-12-19T16:00:03+00:00","breadcrumb":{"@id":"https:\/\/help.r2docuo.com\/en\/knowledge-base\/how-to-run-a-script-when-you-change-the-value-of-a-field-in-the-edit-screen\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/help.r2docuo.com\/en\/knowledge-base\/how-to-run-a-script-when-you-change-the-value-of-a-field-in-the-edit-screen\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/help.r2docuo.com\/en\/knowledge-base\/how-to-run-a-script-when-you-change-the-value-of-a-field-in-the-edit-screen\/#primaryimage","url":"https:\/\/help.r2docuo.com\/wp-content\/uploads\/2023\/12\/image-31.png","contentUrl":"https:\/\/help.r2docuo.com\/wp-content\/uploads\/2023\/12\/image-31.png"},{"@type":"BreadcrumbList","@id":"https:\/\/help.r2docuo.com\/en\/knowledge-base\/how-to-run-a-script-when-you-change-the-value-of-a-field-in-the-edit-screen\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Portada","item":"https:\/\/help.r2docuo.com\/"},{"@type":"ListItem","position":2,"name":"How to run a script when you change the value of a field in the edit screen"}]},{"@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\/5103","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=5103"}],"version-history":[{"count":0,"href":"https:\/\/help.r2docuo.com\/en\/wp-json\/wp\/v2\/ht-kb\/5103\/revisions"}],"wp:attachment":[{"href":"https:\/\/help.r2docuo.com\/en\/wp-json\/wp\/v2\/media?parent=5103"}],"wp:term":[{"taxonomy":"ht_kb_category","embeddable":true,"href":"https:\/\/help.r2docuo.com\/en\/wp-json\/wp\/v2\/ht-kb-category?post=5103"},{"taxonomy":"ht_kb_tag","embeddable":true,"href":"https:\/\/help.r2docuo.com\/en\/wp-json\/wp\/v2\/ht-kb-tag?post=5103"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}