{"id":4800,"date":"2026-04-09T15:53:20","date_gmt":"2026-04-09T19:53:20","guid":{"rendered":"https:\/\/health.uconn.edu\/clinical-research-center\/?page_id=4800"},"modified":"2026-04-09T16:31:17","modified_gmt":"2026-04-09T20:31:17","slug":"redcap-smart-variables","status":"publish","type":"page","link":"https:\/\/health.uconn.edu\/clinical-research-center\/services\/informatics-core\/redcap\/guides-how-tos\/redcap-logic-hub\/redcap-smart-variables\/","title":{"rendered":"REDCap Smart Variables"},"content":{"rendered":"<div class=\"in-page-tabs\"><ul id=\"menu-redcap\" class=\"menu nav nav-tabs\"><li id=\"menu-item-4437\" class=\"menu-item menu-item-type-post_type menu-item-object-page\"><a href=\"https:\/\/health.uconn.edu\/clinical-research-center\/services\/informatics-core\/redcap\/uch-redcap-user-agreement\/\">REDCap User Agreement<\/a><\/li><li id=\"menu-item-4440\" class=\"menu-item menu-item-type-post_type menu-item-object-page\"><a href=\"https:\/\/health.uconn.edu\/clinical-research-center\/services\/informatics-core\/redcap\/redcap-fees\/\">REDCap Fees<\/a><\/li><li id=\"menu-item-4438\" class=\"menu-item menu-item-type-post_type menu-item-object-page\"><a href=\"https:\/\/health.uconn.edu\/clinical-research-center\/services\/informatics-core\/redcap\/redcap-usage\/\">REDCap Usage<\/a><\/li><li id=\"menu-item-4441\" class=\"menu-item menu-item-type-post_type menu-item-object-page\"><a href=\"https:\/\/health.uconn.edu\/clinical-research-center\/services\/informatics-core\/redcap\/redcap-account-request\/\">REDCap Account Request<\/a><\/li><li id=\"menu-item-4446\" class=\"menu-item menu-item-type-post_type menu-item-object-page menu-item-has-children dropdown\"><a href=\"https:\/\/health.uconn.edu\/clinical-research-center\/redcap-login-issues\/\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">REDCap Login Issues<b class=\"caret\"><\/b><\/a>\n<ul class=\"dropdown-menu\">\n\t<li id=\"menu-item-4447\" class=\"menu-item menu-item-type-post_type menu-item-object-page\"><a href=\"https:\/\/health.uconn.edu\/clinical-research-center\/redcap-login-issues\/uchc-user\/\">REDCap Login Help for UConn Health Users<\/a><\/li>\t<li id=\"menu-item-4448\" class=\"menu-item menu-item-type-post_type menu-item-object-page\"><a href=\"https:\/\/health.uconn.edu\/clinical-research-center\/redcap-login-issues\/external-user\/\">UConn &amp; External Users Login Issues<\/a><\/li><!--.dropdown-->\n<\/ul>\n<\/li><li id=\"menu-item-4443\" class=\"menu-item menu-item-type-post_type menu-item-object-page\"><a href=\"https:\/\/health.uconn.edu\/clinical-research-center\/services\/informatics-core\/redcap\/guides-how-tos\/\">REDCap Guides &amp; How-to<\/a><\/li><li id=\"menu-item-4920\" class=\"menu-item menu-item-type-post_type menu-item-object-page\"><a href=\"https:\/\/health.uconn.edu\/clinical-research-center\/data-management\/\">Data Management<\/a><\/li><li id=\"menu-item-4449\" class=\"menu-item menu-item-type-post_type menu-item-object-page menu-item-has-children dropdown\"><a href=\"https:\/\/health.uconn.edu\/clinical-research-center\/services\/informatics-core\/redcap\/scheduled-maintenance\/\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">REDCap Maintenance<b class=\"caret\"><\/b><\/a>\n<ul class=\"dropdown-menu\">\n\t<li id=\"menu-item-4678\" class=\"menu-item menu-item-type-post_type menu-item-object-page\"><a href=\"https:\/\/health.uconn.edu\/clinical-research-center\/services\/informatics-core\/redcap\/scheduled-maintenance\/\">REDCap Maintenance<\/a><\/li>\t<li id=\"menu-item-4450\" class=\"menu-item menu-item-type-post_type menu-item-object-page\"><a href=\"https:\/\/health.uconn.edu\/clinical-research-center\/services\/informatics-core\/redcap\/scheduled-maintenance\/new-features-improvements\/\">REDCap Upgrade Details<\/a><\/li><!--.dropdown-->\n<\/ul>\n<\/li><li id=\"menu-item-4442\" class=\"menu-item menu-item-type-post_type menu-item-object-page\"><a href=\"https:\/\/health.uconn.edu\/clinical-research-center\/services\/informatics-core\/redcap\/redcap-training\/\">REDCap Training Center<\/a><\/li><li id=\"menu-item-4451\" class=\"menu-item menu-item-type-post_type menu-item-object-page\"><a href=\"https:\/\/health.uconn.edu\/clinical-research-center\/services\/informatics-core\/redcap\/redcap-systems\/\">REDCap Systems<\/a><\/li><li id=\"menu-item-4453\" class=\"menu-item menu-item-type-post_type menu-item-object-page\"><a href=\"https:\/\/health.uconn.edu\/clinical-research-center\/services\/informatics-core\/redcap\/citing-redcap\/\">Citing REDCap<\/a><\/li><li id=\"menu-item-4455\" class=\"menu-item menu-item-type-post_type menu-item-object-page\"><a href=\"https:\/\/health.uconn.edu\/clinical-research-center\/services\/informatics-core\/redcap\/redcap_news\/\">REDCap News You Can Use<\/a><\/li><\/ul><\/div><h1 style=\"margin-bottom: 6px;text-align: center\">A Practical Guide to Dynamic Logic and Context-Aware Data:<br \/>\nReference events, records, users, and system data without creating new fields<\/h1>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>Smart Variables allow you to dynamically reference information about the current record, event, user, or system context\u2014without needing to create additional fields. They are especially powerful in longitudinal and repeating projects, and when building advanced logic.<\/p>\n<div style=\"background: #eff6ff;border-left: 6px solid #2563eb;padding: 14px;margin: 22px 0;border-radius: 4px\"><strong>Core Principle:<\/strong> Smart Variables allow you to reference <strong>context<\/strong> (e.g., current event, previous instance, record ID) dynamically within logic, calculations, and other REDCap features.<\/div>\n<div style=\"background: #fff7ed;border-left: 6px solid #ea580c;padding: 14px;margin: 22px 0;border-radius: 4px\"><strong>&#x26a0;&#xfe0f; Important:<\/strong> Smart Variables do not store data\u2014they dynamically return values based on the current context.<\/div>\n<p><!-- TOC --><\/p>\n<div style=\"background: #f0f9ff;border: 1px solid #bae6fd;padding: 16px;border-radius: 6px;margin: 24px 0\">\n<p><strong>On this page<\/strong><\/p>\n<ul style=\"margin: 10px 0 0 20px\">\n<li style=\"list-style-type: none\">\n<ul style=\"margin: 10px 0 0 20px\">\n<li><a href=\"#what\">What Smart Variables Do<\/a><\/li>\n<li><a href=\"#syntax\">Basic Syntax<\/a><\/li>\n<li><a href=\"#types\">Common Smart Variables<\/a><\/li>\n<li><a href=\"#events\">Event-Based Smart Variables<\/a><\/li>\n<li><a href=\"#repeating\">Repeating Instruments<\/a><\/li>\n<li><a href=\"#record\">Record-Level Variables<\/a><\/li>\n<li><a href=\"#user\">User &amp; System Variables<\/a><\/li>\n<li><a href=\"#real-world\">Real-World Examples<\/a><\/li>\n<li><a href=\"#mistakes\">Common Mistakes<\/a><\/li>\n<li><a href=\"#best\">Best Practices<\/a><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/div>\n<hr \/>\n<h2 id=\"what\" style=\"background: #329EB8;color: white;padding: 12px;border-radius: 6px\">What Smart Variables Do<\/h2>\n<ul>\n<li>Reference the current record ID<\/li>\n<li>Pull values from other events<\/li>\n<li>Identify first\/last events or instances<\/li>\n<li>Track user and timestamp information<\/li>\n<li>Enable dynamic logic without extra fields<\/li>\n<\/ul>\n<div style=\"background: #f0fdf4;border-left: 6px solid #16a34a;padding: 12px\"><strong>&#x2705; Best Practice:<\/strong> Use Smart Variables to reduce redundancy and avoid creating unnecessary fields.<\/div>\n<div style=\"text-align: right;margin-top: 14px\"><a href=\"#top\" style=\"background: #eef6f8;color: #1f2937;padding: 6px 12px;text-decoration: none;border-radius: 20px;font-size: 0.95em\">Back to top \u2191<\/a><\/div>\n<hr \/>\n<h2 id=\"syntax\" style=\"background: #329EB8;color: white;padding: 12px;border-radius: 6px\">Basic Syntax<\/h2>\n<p>Smart Variables are referenced using square brackets, just like regular fields:<\/p>\n<pre>[record-id]\r\n[current-event-name]\r\n[first-instance]\r\n<\/pre>\n<div style=\"background: #eff6ff;border-left: 6px solid #2563eb;padding: 12px\"><strong>Tip:<\/strong> Smart Variables can be used anywhere logic is supported (branching, ASIs, Alerts, calculations).<\/div>\n<div style=\"text-align: right;margin-top: 14px\"><a href=\"#top\" style=\"background: #eef6f8;color: #1f2937;padding: 6px 12px;text-decoration: none;border-radius: 20px;font-size: 0.95em\">Back to top \u2191<\/a><\/div>\n<hr \/>\n<h2 id=\"types\" style=\"background: #329EB8;color: white;padding: 12px;border-radius: 6px\">Common Smart Variables<\/h2>\n<table style=\"width: 100%;border-collapse: collapse\">\n<tbody>\n<tr>\n<th style=\"border: 1px solid #ccc;padding: 8px\">Variable<\/th>\n<th style=\"border: 1px solid #ccc;padding: 8px\">Description<\/th>\n<\/tr>\n<tr>\n<td style=\"border: 1px solid #ccc;padding: 8px\"><code>[record-id]<\/code><\/td>\n<td style=\"border: 1px solid #ccc;padding: 8px\">Current record ID<\/td>\n<\/tr>\n<tr>\n<td style=\"border: 1px solid #ccc;padding: 8px\"><code>[event-name]<\/code><\/td>\n<td style=\"border: 1px solid #ccc;padding: 8px\">Current event<\/td>\n<\/tr>\n<tr>\n<td style=\"border: 1px solid #ccc;padding: 8px\"><code>[user-name]<\/code><\/td>\n<td style=\"border: 1px solid #ccc;padding: 8px\">Current user<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<div style=\"text-align: right;margin-top: 14px\"><a href=\"#top\" style=\"background: #eef6f8;color: #1f2937;padding: 6px 12px;text-decoration: none;border-radius: 20px;font-size: 0.95em\">Back to top \u2191<\/a><\/div>\n<hr \/>\n<h2 id=\"events\" style=\"background: #329EB8;color: white;padding: 12px;border-radius: 6px\">Event-Based Smart Variables<\/h2>\n<pre>[first-event-name]\r\n[last-event-name]\r\n[current-event-name]\r\n<\/pre>\n<p>Example:<\/p>\n<pre>[first-event-name][weight]<\/pre>\n<div style=\"background: #fff7ed;border-left: 6px solid #ea580c;padding: 12px\"><strong>&#x26a0;&#xfe0f; Important:<\/strong> Event names must match exactly.<\/div>\n<div style=\"text-align: right;margin-top: 14px\"><a href=\"#top\" style=\"background: #eef6f8;color: #1f2937;padding: 6px 12px;text-decoration: none;border-radius: 20px;font-size: 0.95em\">Back to top \u2191<\/a><\/div>\n<hr \/>\n<h2 id=\"repeating\" style=\"background: #329EB8;color: white;padding: 12px;border-radius: 6px\">Repeating Instruments<\/h2>\n<pre>[first-instance]\r\n[last-instance]\r\n[current-instance]\r\n<\/pre>\n<p>Example:<\/p>\n<pre>[blood_pressure][last-instance]<\/pre>\n<div style=\"background: #eff6ff;border-left: 6px solid #2563eb;padding: 12px\"><strong>Tip:<\/strong> Useful for pulling latest values dynamically.<\/div>\n<div style=\"text-align: right;margin-top: 14px\"><a href=\"#top\" style=\"background: #eef6f8;color: #1f2937;padding: 6px 12px;text-decoration: none;border-radius: 20px;font-size: 0.95em\">Back to top \u2191<\/a><\/div>\n<hr \/>\n<h2 id=\"record\" style=\"background: #329EB8;color: white;padding: 12px;border-radius: 6px\">Record-Level Variables<\/h2>\n<pre>[record-id]\r\n[redcap-event-name]\r\n<\/pre>\n<div style=\"text-align: right;margin-top: 14px\"><a href=\"#top\" style=\"background: #eef6f8;color: #1f2937;padding: 6px 12px;text-decoration: none;border-radius: 20px;font-size: 0.95em\">Back to top \u2191<\/a><\/div>\n<hr \/>\n<h2 id=\"user\" style=\"background: #329EB8;color: white;padding: 12px;border-radius: 6px\">User &amp; System Variables<\/h2>\n<pre>[username]\r\n[user-email]\r\n[today]\r\n[now]\r\n<\/pre>\n<div style=\"background: #fff7ed;border-left: 6px solid #ea580c;padding: 12px\"><strong>&#x26a0;&#xfe0f; Important:<\/strong> Values update dynamically each time accessed.<\/div>\n<div style=\"text-align: right;margin-top: 14px\"><a href=\"#top\" style=\"background: #eef6f8;color: #1f2937;padding: 6px 12px;text-decoration: none;border-radius: 20px;font-size: 0.95em\">Back to top \u2191<\/a><\/div>\n<hr \/>\n<h2 id=\"real-world\" style=\"background: #329EB8;color: white;padding: 12px;border-radius: 6px\">Real-World Examples<\/h2>\n<div style=\"flex-wrap: wrap;gap: 20px\">\n<div style=\"flex: 1;min-width: 250px;border: 1px solid #ccc;padding: 12px;border-radius: 6px\">\n<p><strong>Use Latest Value<\/strong><\/p>\n<pre>[weight][last-instance]<\/pre>\n<\/div>\n<div style=\"flex: 1;min-width: 250px;border: 1px solid #ccc;padding: 12px;border-radius: 6px\">\n<p><strong>Reference Baseline<\/strong><\/p>\n<pre>[first-event-name][age]<\/pre>\n<\/div>\n<div style=\"flex: 1;min-width: 250px;border: 1px solid #ccc;padding: 12px;border-radius: 6px\">\n<p><strong>Timestamp<\/strong><\/p>\n<pre>[now]<\/pre>\n<\/div>\n<\/div>\n<div style=\"text-align: right;margin-top: 14px\"><a href=\"#top\" style=\"background: #eef6f8;color: #1f2937;padding: 6px 12px;text-decoration: none;border-radius: 20px;font-size: 0.95em\">Back to top \u2191<\/a><\/div>\n<hr \/>\n<h2 id=\"mistakes\" style=\"background: #329EB8;color: white;padding: 12px;border-radius: 6px\">Common Mistakes<\/h2>\n<ul>\n<li>&#x274c; Treating Smart Variables like stored data<\/li>\n<li>&#x274c; Incorrect event names<\/li>\n<li>&#x274c; Using without testing context<\/li>\n<\/ul>\n<div style=\"text-align: right;margin-top: 14px\"><a href=\"#top\" style=\"background: #eef6f8;color: #1f2937;padding: 6px 12px;text-decoration: none;border-radius: 20px;font-size: 0.95em\">Back to top \u2191<\/a><\/div>\n<hr \/>\n<h2 id=\"best\" style=\"background: #16a34a;color: white;padding: 12px;border-radius: 6px\">Best Practices<\/h2>\n<ul>\n<li>Use for dynamic references<\/li>\n<li>Test in real records<\/li>\n<li>Keep logic readable<\/li>\n<\/ul>\n<div style=\"text-align: right;margin-top: 14px\"><a href=\"#top\" style=\"background: #eef6f8;color: #1f2937;padding: 6px 12px;text-decoration: none;border-radius: 20px;font-size: 0.95em\">Back to top \u2191<\/a><\/div>\n<hr \/>\n","protected":false},"excerpt":{"rendered":"<p>REDCap User AgreementREDCap FeesREDCap UsageREDCap Account RequestREDCap Login Issues REDCap Login Help for UConn Health Users UConn &amp; External Users Login Issues REDCap Guides &amp; How-toData ManagementREDCap Maintenance REDCap Maintenance REDCap Upgrade Details REDCap Training CenterREDCap SystemsCiting REDCapREDCap News You Can UseA Practical Guide to Dynamic Logic and Context-Aware Data: Reference events, records, users, and [&hellip;]<\/p>\n","protected":false},"author":4679,"featured_media":0,"parent":4778,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_acf_changed":false,"footnotes":""},"acf":[],"publishpress_future_action":{"enabled":false,"date":"2026-05-29 08:48:17","action":"change-status","newStatus":"draft","terms":[],"taxonomy":""},"_links":{"self":[{"href":"https:\/\/health.uconn.edu\/clinical-research-center\/wp-json\/wp\/v2\/pages\/4800"}],"collection":[{"href":"https:\/\/health.uconn.edu\/clinical-research-center\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/health.uconn.edu\/clinical-research-center\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/health.uconn.edu\/clinical-research-center\/wp-json\/wp\/v2\/users\/4679"}],"replies":[{"embeddable":true,"href":"https:\/\/health.uconn.edu\/clinical-research-center\/wp-json\/wp\/v2\/comments?post=4800"}],"version-history":[{"count":8,"href":"https:\/\/health.uconn.edu\/clinical-research-center\/wp-json\/wp\/v2\/pages\/4800\/revisions"}],"predecessor-version":[{"id":4812,"href":"https:\/\/health.uconn.edu\/clinical-research-center\/wp-json\/wp\/v2\/pages\/4800\/revisions\/4812"}],"up":[{"embeddable":true,"href":"https:\/\/health.uconn.edu\/clinical-research-center\/wp-json\/wp\/v2\/pages\/4778"}],"wp:attachment":[{"href":"https:\/\/health.uconn.edu\/clinical-research-center\/wp-json\/wp\/v2\/media?parent=4800"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}