{"id":1688362,"date":"2022-08-22T09:30:37","date_gmt":"2022-08-22T16:30:37","guid":{"rendered":"https:\/\/www.esri.com\/arcgis-blog\/?post_type=blog&#038;p=1688362"},"modified":"2024-10-31T23:59:37","modified_gmt":"2024-11-01T06:59:37","slug":"execute-arcade-expressions-on-your-terms","status":"publish","type":"blog","link":"https:\/\/www.esri.com\/arcgis-blog\/products\/js-api-arcgis\/developers\/execute-arcade-expressions-on-your-terms","title":{"rendered":"Execute Arcade expressions on your terms"},"author":6561,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"open","ping_status":"closed","template":"","format":"standard","meta":{"_acf_changed":false,"_searchwp_excluded":""},"categories":[777102,738191,22941],"tags":[32551],"industry":[],"product":[761642,36831,763892,36601],"class_list":["post-1688362","blog","type-blog","status-publish","format-standard","hentry","category-arcade","category-developers","category-mapping","tag-arcade","product-platform","product-js-api-arcgis","product-runtime-sdk","product-developers"],"acf":{"short_description":"Have you ever wanted to run an Arcade script outside of a traditional Arcade profile? Now you can.","flexible_content":[{"acf_fc_layout":"content","content":"<p>I\u2019ve been presenting and writing about <a href=\"https:\/\/developers.arcgis.com\/arcade\/\">ArcGIS Arcade<\/a> since it was first released in late 2016. One of the most common questions people have asked me over the years is &#8220;What if I want to use Arcade for something else?&#8221; and &#8220;How can I execute Arcade outside of Esri\u2019s predefined profiles?&#8221;<\/p>\n<p>Up until recently, Arcade\u2019s execution was strictly constrained to <a href=\"https:\/\/developers.arcgis.com\/arcade\/guide\/profiles\/\">profiles<\/a>, such as a layer\u2019s <a href=\"https:\/\/developers.arcgis.com\/javascript\/latest\/arcade\/#popups\">popup<\/a> or <a href=\"https:\/\/developers.arcgis.com\/javascript\/latest\/arcade\/#visualization\">renderer<\/a>. Earlier this year, the <a href=\"https:\/\/developers.arcgis.com\/javascript\/latest\/\">ArcGIS API for JavaScript<\/a> and the <a href=\"https:\/\/developers.arcgis.com\/net\/\">ArcGIS Runtime SDKs<\/a> released the following Arcade executor APIs, which allow you to evaluate Arcade expressions outside predefined profiles.<\/p>\n<ul>\n<li><a href=\"https:\/\/developers.arcgis.com\/javascript\/latest\/api-reference\/esri-arcade.html#createArcadeExecutor\">ArcadeExecutor (JavaScript)<\/a><\/li>\n<li><a href=\"https:\/\/developers.arcgis.com\/net\/api-reference\/api\/netwin\/Esri.ArcGISRuntime\/Esri.ArcGISRuntime.Arcade.ArcadeEvaluator.html\">ArcadeEvaluator (.NET)<\/a><\/li>\n<li><a href=\"https:\/\/developers.arcgis.com\/java\/api-reference\/reference\/com\/esri\/arcgisruntime\/arcade\/ArcadeEvaluator.html\">ArcadeEvaluator (Java)<\/a><\/li>\n<\/ul>\n<p>In this post, I&#8217;ll demonstrate how to execute Arcade outside the context of a web map, to create a scatterplot complimenting the map.<\/p>\n"},{"acf_fc_layout":"image","image":{"ID":1690542,"id":1690542,"title":"Screen Shot 2022-08-19 at 9.36.25 AM","filename":"Screen-Shot-2022-08-19-at-9.36.25-AM.png","filesize":273012,"url":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2022\/08\/Screen-Shot-2022-08-19-at-9.36.25-AM.png","link":"https:\/\/www.esri.com\/arcgis-blog\/products\/js-api-arcgis\/developers\/execute-arcade-expressions-on-your-terms\/screen-shot-2022-08-19-at-9-36-25-am","alt":"The language diversity index in this map is calculated with an Arcade expression in the layer's renderer. To display a complimentary chart with this information, you must execute the expression for each data point outside the context of the renderer.","author":"6561","description":"","caption":"The language diversity index in this map is calculated with an Arcade expression in the layer's renderer. To display a complimentary chart with this information, you must execute the expression for each data point outside the context of the renderer.","name":"screen-shot-2022-08-19-at-9-36-25-am","status":"inherit","uploaded_to":1688362,"date":"2022-08-19 16:37:12","modified":"2022-08-19 16:38:44","menu_order":0,"mime_type":"image\/png","type":"image","subtype":"png","icon":"https:\/\/www.esri.com\/arcgis-blog\/wp-includes\/images\/media\/default.png","width":1278,"height":742,"sizes":{"thumbnail":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2022\/08\/Screen-Shot-2022-08-19-at-9.36.25-AM-213x200.png","thumbnail-width":213,"thumbnail-height":200,"medium":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2022\/08\/Screen-Shot-2022-08-19-at-9.36.25-AM.png","medium-width":450,"medium-height":261,"medium_large":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2022\/08\/Screen-Shot-2022-08-19-at-9.36.25-AM.png","medium_large-width":768,"medium_large-height":446,"large":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2022\/08\/Screen-Shot-2022-08-19-at-9.36.25-AM.png","large-width":1278,"large-height":742,"1536x1536":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2022\/08\/Screen-Shot-2022-08-19-at-9.36.25-AM.png","1536x1536-width":1278,"1536x1536-height":742,"2048x2048":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2022\/08\/Screen-Shot-2022-08-19-at-9.36.25-AM.png","2048x2048-width":1278,"2048x2048-height":742,"card_image":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2022\/08\/Screen-Shot-2022-08-19-at-9.36.25-AM-801x465.png","card_image-width":801,"card_image-height":465,"wide_image":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2022\/08\/Screen-Shot-2022-08-19-at-9.36.25-AM.png","wide_image-width":1278,"wide_image-height":742}},"image_position":"center","orientation":"horizontal","hyperlink":"https:\/\/developers.arcgis.com\/javascript\/latest\/sample-code\/arcade-execute-chart\/"},{"acf_fc_layout":"sidebar","content":"<p><strong>A word of caution<\/strong><\/p>\n<p>Keep in mind that Arcade is most powerful when used in the context of a web map or portal where expressions can be saved and consumed in a variety of apps. If you are unfamiliar with Arcade, I encourage you to first read <a href=\"https:\/\/www.esri.com\/arcgis-blog\/products\/js-api-arcgis\/developers\/im-a-developer-do-i-really-need-arcade\/\">I\u2019m a developer. Do I really need Arcade?<\/a> which demonstrates how Arcade works and why it can be a powerful tool in customizing ArcGIS apps.<\/p>\n","image_reference":false,"layout":"standard","image_reference_figure":"","snippet":"","spotlight_name":"","section_title":"","position":"Center","spotlight_image":false},{"acf_fc_layout":"content","content":"<h2>Profiles<\/h2>\n<p>The <a href=\"https:\/\/developers.arcgis.com\/arcade\/\">Arcade documentation<\/a> refers to a script\u2019s execution context as its <strong>profile<\/strong>. An Arcade profile specifies:<\/p>\n<ul>\n<li><strong>where<\/strong> you can use Arcade,<\/li>\n<li>the <strong>profile variables<\/strong> (aka globals) that can be used as input data values to the expression,<\/li>\n<li>the language <strong>functions<\/strong> you may use, and<\/li>\n<li>the valid <strong>data types<\/strong> that may be returned from an expression.<\/li>\n<\/ul>\n<p>Another way to think of a profile is the <strong>environment<\/strong> that controls Arcade\u2019s execution. There are more than 20 profiles that allow you to author Arcade expressions for various purposes. Some examples include <a href=\"https:\/\/developers.arcgis.com\/arcade\/guide\/profiles\/#popups\">popups<\/a>, <a href=\"https:\/\/developers.arcgis.com\/arcade\/guide\/profiles\/#visualization\">visualization<\/a>, <a href=\"https:\/\/developers.arcgis.com\/arcade\/guide\/profiles\/#labeling\">labels<\/a>, and <a href=\"https:\/\/developers.arcgis.com\/arcade\/guide\/profiles\/#attribute-rules\">attribute rules<\/a>.<\/p>\n"},{"acf_fc_layout":"image","image":{"ID":1683762,"id":1683762,"title":"Screen Shot 2022-08-11 at 4.29.30 PM","filename":"Screen-Shot-2022-08-11-at-4.29.30-PM-scaled.png","filesize":926741,"url":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2022\/08\/Screen-Shot-2022-08-11-at-4.29.30-PM-scaled.png","link":"https:\/\/www.esri.com\/arcgis-blog\/products\/js-api-arcgis\/developers\/im-a-developer-do-i-really-need-arcade\/screen-shot-2022-08-11-at-4-29-30-pm","alt":"Arcade profiles supported by the ArcGIS API for JavaScript. Profiles define the context, variables, valid return types, and functions that may be used in expressions.","author":"6561","description":"","caption":"Arcade profiles implemented in the ArcGIS API for JavaScript. Profiles define the context, variables, valid return types, and functions that may be used in expressions.","name":"screen-shot-2022-08-11-at-4-29-30-pm","status":"inherit","uploaded_to":1683632,"date":"2022-08-11 23:30:05","modified":"2022-08-12 16:36:18","menu_order":0,"mime_type":"image\/png","type":"image","subtype":"png","icon":"https:\/\/www.esri.com\/arcgis-blog\/wp-includes\/images\/media\/default.png","width":2560,"height":1355,"sizes":{"thumbnail":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2022\/08\/Screen-Shot-2022-08-11-at-4.29.30-PM-213x200.png","thumbnail-width":213,"thumbnail-height":200,"medium":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2022\/08\/Screen-Shot-2022-08-11-at-4.29.30-PM-scaled.png","medium-width":464,"medium-height":246,"medium_large":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2022\/08\/Screen-Shot-2022-08-11-at-4.29.30-PM-scaled.png","medium_large-width":768,"medium_large-height":407,"large":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2022\/08\/Screen-Shot-2022-08-11-at-4.29.30-PM-scaled.png","large-width":1920,"large-height":1016,"1536x1536":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2022\/08\/Screen-Shot-2022-08-11-at-4.29.30-PM-1536x813.png","1536x1536-width":1536,"1536x1536-height":813,"2048x2048":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2022\/08\/Screen-Shot-2022-08-11-at-4.29.30-PM-2048x1084.png","2048x2048-width":2048,"2048x2048-height":1084,"card_image":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2022\/08\/Screen-Shot-2022-08-11-at-4.29.30-PM-826x437.png","card_image-width":826,"card_image-height":437,"wide_image":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2022\/08\/Screen-Shot-2022-08-11-at-4.29.30-PM-1920x1016.png","wide_image-width":1920,"wide_image-height":1016}},"image_position":"center","orientation":"horizontal","hyperlink":""},{"acf_fc_layout":"content","content":"<h2>Cases when you need Arcade executed outside its designated profile<\/h2>\n<p>The Arcade profiles already implemented in ArcGIS apps and developer products are sufficient for <a href=\"https:\/\/www.esri.com\/arcgis-blog\/products\/js-api-arcgis\/developers\/im-a-developer-do-i-really-need-arcade\/\">enabling users to customize apps in a vast majority of cases<\/a>. However, there are a few scenarios where you may need to display the result of an expression in a custom element or use it as input for some other task. The following are common workflows that would require you to execute Arcade outside an existing Arcade context.<\/p>\n<ul>\n<li><strong>When you need to use the result of an expression defined in a web map in another context outside the map.<\/strong> For example, an end user may have written an expression for a renderer, popup, or label in a web map and the data returned from the expression should be displayed outside the map in a custom component, table, or summarized in a chart.<\/li>\n<li><strong>When you need to define a custom Arcade profile<\/strong> and provide a configurable experience within an app for users to write their own expressions.<\/li>\n<li><strong>Developers may want to take advantage of Arcade&#8217;s simplified language syntax<\/strong> for filtering and querying data using the chain-able <a href=\"https:\/\/developers.arcgis.com\/arcade\/guide\/types\/#featureset\">FeatureSet<\/a> functions Arcade provides.<\/li>\n<\/ul>\n<p>This post will demonstrate the first scenario using the <a href=\"https:\/\/developers.arcgis.com\/javascript\/latest\/api-reference\/esri-arcade.html\">esri\/arcade<\/a> module <a href=\"https:\/\/developers.arcgis.com\/javascript\/latest\/4.24\/#execute-arcade-expressions\">added in version 4.24<\/a> of the ArcGIS API for JavaScript. We&#8217;ll follow the steps below to display the results of an Arcade expression in a chart outside the context of a web map.<\/p>\n<ol>\n<li>Load the web map<\/li>\n<li>Get the Arcade expression<\/li>\n<li>Define the profile variables<\/li>\n<li>Create an Arcade executor<\/li>\n<li>Execute the script<\/li>\n<\/ol>\n"},{"acf_fc_layout":"content","content":"<h2>1. Load the web map<\/h2>\n<p>When a user authors an Arcade expression in the ArcGIS Online Map Viewer, or in another app like ArcGIS Pro, that expression can be saved in the context where it was defined.<\/p>\n<p>For example <a href=\"https:\/\/www.arcgis.com\/apps\/mapviewer\/index.html?webmap=a7fb72d99a9b4e15b811ee60c04fdfc1\">this web map<\/a> defines the following expression in the layer&#8217;s style to create a diversity map of languages spoken in U.S. homes.<\/p>\n<pre><code style=\"padding: 0.5em; color: #333; background: #f8f8f8;\"><span style=\"color: #333; font-weight: bold;\">var<\/span> english = $feature[<span style=\"color: #d14;\">\"B16007_calc_numEngOnlyE\"<\/span>];\r\n<span style=\"color: #333; font-weight: bold;\">var<\/span> spanish = $feature[<span style=\"color: #d14;\">\"B16007_calc_numSpanE\"<\/span>];\r\n<span style=\"color: #333; font-weight: bold;\">var<\/span> asianLanguages = $feature[<span style=\"color: #d14;\">\"B16007_calc_numAPIE\"<\/span>];\r\n<span style=\"color: #333; font-weight: bold;\">var<\/span> europeanLanguages = $feature[<span style=\"color: #d14;\">\"B16007_calc_numIEE\"<\/span>];\r\n<span style=\"color: #333; font-weight: bold;\">var<\/span> otherLanguages = $feature[<span style=\"color: #d14;\">\"B16007_calc_numOtherE\"<\/span>];\r\n\r\n<span style=\"color: #333; font-weight: bold;\">var<\/span> groups = [\r\n  english,\r\n  spanish,\r\n  asianLanguages,\r\n  europeanLanguages,\r\n  otherLanguages,\r\n];\r\n\r\n<span style=\"color: #333; font-weight: bold;\">function<\/span> <span style=\"color: #900; font-weight: bold;\">simpsonsDiversityIndex<\/span>(vals){\r\n  <span style=\"color: #333; font-weight: bold;\">var<\/span> k = <span style=\"color: #0086b3;\">Array<\/span>(Count(vals));\r\n  <span style=\"color: #333; font-weight: bold;\">var<\/span> t = sum(vals);\r\n  <span style=\"color: #333; font-weight: bold;\">for<\/span>(<span style=\"color: #333; font-weight: bold;\">var<\/span> i <span style=\"color: #333; font-weight: bold;\">in<\/span> vals){\r\n    <span style=\"color: #333; font-weight: bold;\">var<\/span> n = vals[i];\r\n    k[i] = n * (n-<span style=\"color: #008080;\">1<\/span>);\r\n  }\r\n  <span style=\"color: #333; font-weight: bold;\">var<\/span> s = Sum(k);\r\n  <span style=\"color: #333; font-weight: bold;\">var<\/span> di = <span style=\"color: #008080;\">1<\/span> - ( s  \/ ( t * (t-<span style=\"color: #008080;\">1<\/span>) ) );\r\n  <span style=\"color: #333; font-weight: bold;\">return<\/span> Round(di*<span style=\"color: #008080;\">100<\/span>);\r\n}\r\n\r\nsimpsonsDiversityIndex(groups);\r\n<\/code><\/pre>\n"},{"acf_fc_layout":"image","image":{"ID":1690562,"id":1690562,"title":"Screen Shot 2022-08-19 at 9.54.28 AM","filename":"Screen-Shot-2022-08-19-at-9.54.28-AM.png","filesize":219345,"url":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2022\/08\/Screen-Shot-2022-08-19-at-9.54.28-AM.png","link":"https:\/\/www.esri.com\/arcgis-blog\/products\/js-api-arcgis\/developers\/execute-arcade-expressions-on-your-terms\/screen-shot-2022-08-19-at-9-54-28-am","alt":"The diversity index data represented by the colors in this web map are returned from an Arcade expression. The layer's renderer controls the execution of Arcade and keeps it contained so the output values cannot be used or referenced in other parts of the app.","author":"6561","description":"","caption":"The diversity index data represented by the colors in this web map are returned from an Arcade expression. The layer's renderer controls the execution of Arcade and keeps it contained so the output values cannot be used or referenced in other parts of the app.","name":"screen-shot-2022-08-19-at-9-54-28-am","status":"inherit","uploaded_to":1688362,"date":"2022-08-19 16:54:50","modified":"2022-08-19 16:57:56","menu_order":0,"mime_type":"image\/png","type":"image","subtype":"png","icon":"https:\/\/www.esri.com\/arcgis-blog\/wp-includes\/images\/media\/default.png","width":1324,"height":610,"sizes":{"thumbnail":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2022\/08\/Screen-Shot-2022-08-19-at-9.54.28-AM-213x200.png","thumbnail-width":213,"thumbnail-height":200,"medium":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2022\/08\/Screen-Shot-2022-08-19-at-9.54.28-AM.png","medium-width":464,"medium-height":214,"medium_large":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2022\/08\/Screen-Shot-2022-08-19-at-9.54.28-AM.png","medium_large-width":768,"medium_large-height":354,"large":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2022\/08\/Screen-Shot-2022-08-19-at-9.54.28-AM.png","large-width":1324,"large-height":610,"1536x1536":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2022\/08\/Screen-Shot-2022-08-19-at-9.54.28-AM.png","1536x1536-width":1324,"1536x1536-height":610,"2048x2048":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2022\/08\/Screen-Shot-2022-08-19-at-9.54.28-AM.png","2048x2048-width":1324,"2048x2048-height":610,"card_image":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2022\/08\/Screen-Shot-2022-08-19-at-9.54.28-AM-826x381.png","card_image-width":826,"card_image-height":381,"wide_image":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2022\/08\/Screen-Shot-2022-08-19-at-9.54.28-AM.png","wide_image-width":1324,"wide_image-height":610}},"image_position":"center","orientation":"horizontal","hyperlink":"https:\/\/www.arcgis.com\/apps\/mapviewer\/index.html?webmap=a7fb72d99a9b4e15b811ee60c04fdfc1"},{"acf_fc_layout":"content","content":"<p>To <a href=\"https:\/\/developers.arcgis.com\/javascript\/latest\/sample-code\/webmap-basic\/\">load the web map<\/a>, reference the <a href=\"https:\/\/developers.arcgis.com\/javascript\/latest\/api-reference\/esri-portal-PortalItem.html#id\">portal item ID<\/a> in the <code>portalItem<\/code> property of the <a href=\"https:\/\/developers.arcgis.com\/javascript\/latest\/api-reference\/esri-WebMap.html\">WebMap<\/a> class.<\/p>\n<pre><code style=\"padding: 0.5em; color: #333; background: #f8f8f8;\"><span style=\"color: #333; font-weight: bold;\">const<\/span> view = <span style=\"color: #333; font-weight: bold;\">new<\/span> MapView({\r\n  map: <span style=\"color: #333; font-weight: bold;\">new<\/span> WebMap({\r\n    portalItem: {\r\n      id: <span style=\"color: #d14;\">\"a7fb72d99a9b4e15b811ee60c04fdfc1\"<\/span>\r\n    }\r\n  }),\r\n  container: <span style=\"color: #d14;\">\"viewDiv\"<\/span>,\r\n});\r\n<\/code><\/pre>\n<h2>2. Get the Arcade expression<\/h2>\n<p>The Arcade expression is defined in the <a href=\"https:\/\/developers.arcgis.com\/javascript\/latest\/api-reference\/esri-renderers-visualVariables-ColorVariable.html#valueExpression\">valueExpression<\/a> property of a <a href=\"https:\/\/developers.arcgis.com\/javascript\/latest\/api-reference\/esri-renderers-visualVariables-ColorVariable.html\">color visual variable<\/a>. You need to wait for the view&#8217;s resources to load before drilling into the renderer to retrieve the expression.<\/p>\n<pre><code style=\"padding: 0.5em; color: #333; background: #f8f8f8;\"><span style=\"color: #333; font-weight: bold;\">await<\/span> view.when();\r\n\r\n<span style=\"color: #998; font-style: italic;\">\/\/ Get layer containing Arcade expression from webmap<\/span>\r\n<span style=\"color: #333; font-weight: bold;\">const<\/span> spanishSpeakersLayer = view.map.layers.find(\r\n  ({title}) =&gt; title === <span style=\"color: #d14;\">\"Language diversity in Spanish speaking populations\"<\/span>\r\n);\r\n\r\n<span style=\"color: #998; font-style: italic;\">\/\/ Get visual variable containing the Arcade expression<\/span>\r\n<span style=\"color: #333; font-weight: bold;\">const<\/span> renderer = spanishSpeakersLayer.renderer;\r\n<span style=\"color: #333; font-weight: bold;\">const<\/span> colorVariable = renderer.visualVariables.find( vv =&gt; vv.type === <span style=\"color: #d14;\">\"color\"<\/span>);\r\n\r\n<span style=\"color: #998; font-style: italic;\">\/\/ Arcade expression used by color visual variable<\/span>\r\n<span style=\"color: #333; font-weight: bold;\">const<\/span> diversityArcadeScript = colorVariable.valueExpression;\r\n\r\n<\/code><\/pre>\n<h2>3. Define the profile variables<\/h2>\n<p>Arcade requires a profile, or a context, in which to execute. The <a href=\"https:\/\/developers.arcgis.com\/javascript\/latest\/api-reference\/esri-arcade.html#ArcadeExecutor\">ArcadeExecutor<\/a> creates this context, but you first need to <a href=\"https:\/\/developers.arcgis.com\/javascript\/latest\/api-reference\/esri-arcade.html#Profile\">provide it with valid profile variables<\/a> so the Arcade compiler can validate whether the expression is written for the right context.<\/p>\n<p>In the case of the language diversity expression, it was defined for a visual variable in a renderer. Therefore, it should execute within the context of the <a href=\"https:\/\/developers.arcgis.com\/arcade\/guide\/profiles\/#visualization\">Visualization profile<\/a>. The Arcade documentation defines the valid profile variables and expected output types in the <a href=\"https:\/\/developers.arcgis.com\/arcade\/guide\/profiles\/#visualization\">Visualization profile specification<\/a>.<\/p>\n<p>In the ArcGIS API for JavaScript, <a href=\"https:\/\/developers.arcgis.com\/javascript\/latest\/api-reference\/esri-arcade.html#ProfileVariable\">profile variables<\/a> are defined as plain objects specifying the name of each variable along with its <a href=\"https:\/\/developers.arcgis.com\/arcade\/guide\/types\/\">Arcade data type<\/a>.<\/p>\n<pre><code style=\"padding: 0.5em; color: #333; background: #f8f8f8;\"><span style=\"color: #333; font-weight: bold;\">const<\/span> visualizationProfile = {\r\n  variables: [{\r\n    name: <span style=\"color: #d14;\">\"$feature\"<\/span>,\r\n    type: <span style=\"color: #d14;\">\"feature\"<\/span>\r\n  }, {\r\n    name: <span style=\"color: #d14;\">\"$view\"<\/span>,\r\n    type: <span style=\"color: #d14;\">\"dictionary\"<\/span>,\r\n    properties: [{\r\n      name: <span style=\"color: #d14;\">\"scale\"<\/span>,\r\n      type: <span style=\"color: #d14;\">\"number\"<\/span>\r\n    }]\r\n  }]\r\n};\r\n<\/code><\/pre>\n<h2>4. Create an Arcade executor<\/h2>\n<p>Now the expression is ready to compile. We must provide both the expression and the profile definition to the <a href=\"https:\/\/developers.arcgis.com\/javascript\/latest\/api-reference\/esri-arcade.html#createArcadeExecutor\">createArcadeExecutor<\/a> method, which compiles the script and validates it. If the script validates without compilation errors, the method will return an <a href=\"https:\/\/developers.arcgis.com\/javascript\/latest\/api-reference\/esri-arcade.html#ArcadeExecutor\">ArcadeExecutor<\/a> object, which provides metadata about the expression and methods for executing it.<\/p>\n<pre><code style=\"padding: 0.5em; color: #333; background: #f8f8f8;\"><span style=\"color: #998; font-style: italic;\">\/\/ Compile the Arcade expression and create an executor<\/span>\r\n<span style=\"color: #333; font-weight: bold;\">const<\/span> diversityArcadeExecutor =\r\n  <span style=\"color: #333; font-weight: bold;\">await<\/span> arcade.createArcadeExecutor(diversityArcadeScript, visualizationProfile);\r\n<\/code><\/pre>\n<p>The executor will throw an error if there are any problems during the compilation of the script, such as usage of an undeclared variable, an improper function call, or a reference to an invalid profile variable.<\/p>\n"},{"acf_fc_layout":"image","image":{"ID":1690512,"id":1690512,"title":"Screen Shot 2022-08-16 at 11.15.38 AM","filename":"Screen-Shot-2022-08-16-at-11.15.38-AM.png","filesize":72379,"url":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2022\/08\/Screen-Shot-2022-08-16-at-11.15.38-AM.png","link":"https:\/\/www.esri.com\/arcgis-blog\/products\/js-api-arcgis\/developers\/execute-arcade-expressions-on-your-terms\/screen-shot-2022-08-16-at-11-15-38-am","alt":"The script provided to the createArcadeExecutor method improperly calls the Sum function resulting in the compiler to throw an error. The compiler will validate a script's syntax, including valid use of profile variables.","author":"6561","description":"","caption":"The script provided to the createArcadeExecutor method improperly calls the Sum function resulting in the compiler to throw an error. The compiler will validate a script's syntax, including valid use of profile variables.","name":"screen-shot-2022-08-16-at-11-15-38-am","status":"inherit","uploaded_to":1688362,"date":"2022-08-19 16:18:43","modified":"2022-08-19 16:21:16","menu_order":0,"mime_type":"image\/png","type":"image","subtype":"png","icon":"https:\/\/www.esri.com\/arcgis-blog\/wp-includes\/images\/media\/default.png","width":1205,"height":188,"sizes":{"thumbnail":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2022\/08\/Screen-Shot-2022-08-16-at-11.15.38-AM-213x188.png","thumbnail-width":213,"thumbnail-height":188,"medium":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2022\/08\/Screen-Shot-2022-08-16-at-11.15.38-AM.png","medium-width":464,"medium-height":72,"medium_large":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2022\/08\/Screen-Shot-2022-08-16-at-11.15.38-AM.png","medium_large-width":768,"medium_large-height":120,"large":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2022\/08\/Screen-Shot-2022-08-16-at-11.15.38-AM.png","large-width":1205,"large-height":188,"1536x1536":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2022\/08\/Screen-Shot-2022-08-16-at-11.15.38-AM.png","1536x1536-width":1205,"1536x1536-height":188,"2048x2048":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2022\/08\/Screen-Shot-2022-08-16-at-11.15.38-AM.png","2048x2048-width":1205,"2048x2048-height":188,"card_image":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2022\/08\/Screen-Shot-2022-08-16-at-11.15.38-AM-826x129.png","card_image-width":826,"card_image-height":129,"wide_image":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2022\/08\/Screen-Shot-2022-08-16-at-11.15.38-AM.png","wide_image-width":1205,"wide_image-height":188}},"image_position":"center","orientation":"horizontal","hyperlink":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2022\/08\/Screen-Shot-2022-08-16-at-11.15.38-AM.png"},{"acf_fc_layout":"content","content":"<p>You shouldn&#8217;t find compilation errors when working with expressions from web maps since the ArcGIS Online map viewer blocks bad Arcade expressions from being saved.<\/p>\n<p>When compilation succeeds, an <a href=\"https:\/\/developers.arcgis.com\/javascript\/latest\/api-reference\/esri-arcade.html#ArcadeExecutor\">ArcadeExecutor<\/a> object is returned. This object contains synchronous and asynchronous <a href=\"https:\/\/developers.arcgis.com\/javascript\/latest\/api-reference\/esri-arcade.html#ExecuteFunction\">execute methods<\/a> that allow you to evaluate the expression.<\/p>\n"},{"acf_fc_layout":"image","image":{"ID":1690522,"id":1690522,"title":"Screen Shot 2022-08-16 at 11.26.03 AM","filename":"Screen-Shot-2022-08-16-at-11.26.03-AM.png","filesize":26000,"url":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2022\/08\/Screen-Shot-2022-08-16-at-11.26.03-AM.png","link":"https:\/\/www.esri.com\/arcgis-blog\/products\/js-api-arcgis\/developers\/execute-arcade-expressions-on-your-terms\/screen-shot-2022-08-16-at-11-26-03-am","alt":"The ArcadeExecutor provides methods for executing the script, and indicates which data fields were referenced in the expression.","author":"6561","description":"","caption":"The ArcadeExecutor provides methods for executing the script, and indicates which data fields were referenced in the expression.","name":"screen-shot-2022-08-16-at-11-26-03-am","status":"inherit","uploaded_to":1688362,"date":"2022-08-19 16:23:02","modified":"2022-08-22 16:13:26","menu_order":0,"mime_type":"image\/png","type":"image","subtype":"png","icon":"https:\/\/www.esri.com\/arcgis-blog\/wp-includes\/images\/media\/default.png","width":276,"height":220,"sizes":{"thumbnail":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2022\/08\/Screen-Shot-2022-08-16-at-11.26.03-AM-213x200.png","thumbnail-width":213,"thumbnail-height":200,"medium":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2022\/08\/Screen-Shot-2022-08-16-at-11.26.03-AM.png","medium-width":276,"medium-height":220,"medium_large":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2022\/08\/Screen-Shot-2022-08-16-at-11.26.03-AM.png","medium_large-width":276,"medium_large-height":220,"large":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2022\/08\/Screen-Shot-2022-08-16-at-11.26.03-AM.png","large-width":276,"large-height":220,"1536x1536":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2022\/08\/Screen-Shot-2022-08-16-at-11.26.03-AM.png","1536x1536-width":276,"1536x1536-height":220,"2048x2048":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2022\/08\/Screen-Shot-2022-08-16-at-11.26.03-AM.png","2048x2048-width":276,"2048x2048-height":220,"card_image":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2022\/08\/Screen-Shot-2022-08-16-at-11.26.03-AM.png","card_image-width":276,"card_image-height":220,"wide_image":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2022\/08\/Screen-Shot-2022-08-16-at-11.26.03-AM.png","wide_image-width":276,"wide_image-height":220}},"image_position":"center","orientation":"horizontal","hyperlink":""},{"acf_fc_layout":"content","content":"<p>It\u2019s worth noting the <code>fieldsUsed<\/code> property of the executor object. This property will list all fields required as inputs for the expression to successfully evaluate. This is important because you need to ensure those attributes are available and downloaded to the client for the script to return valid output.<\/p>\n<p>You should set the <code>fieldsUsed<\/code> to the <a href=\"https:\/\/developers.arcgis.com\/javascript\/latest\/api-reference\/esri-layers-FeatureLayer.html#outFields\">outFields<\/a> property of the source layer of the features used as inputs to the expression. Failing to do this is the equivalent of attempting to call a function without all the required input values.<\/p>\n<pre><code style=\"padding: 0.5em; color: #333; background: #f8f8f8;\"><span style=\"color: #998; font-style: italic;\">\/\/ Compile the Arcade expression and create an executor<\/span>\r\n<span style=\"color: #333; font-weight: bold;\">const<\/span> diversityArcadeExecutor =\r\n  <span style=\"color: #333; font-weight: bold;\">await<\/span> arcade.createArcadeExecutor(diversityArcadeScript, visualizationProfile);\r\n\r\n<span style=\"color: #998; font-style: italic;\">\/\/ Ensure the input to $feature has all the<\/span>\r\n<span style=\"color: #998; font-style: italic;\">\/\/ data required by the expression.<\/span>\r\n<span style=\"color: #998; font-style: italic;\">\/\/ The additional field listed below is required by the y axis of<\/span>\r\n<span style=\"color: #998; font-style: italic;\">\/\/ the chart, but not used in the Arcade expression.<\/span>\r\nspanishSpeakersLayer.outFields = [\r\n  ...diversityArcadeExecutor.fieldsUsed,\r\n  <span style=\"color: #d14;\">\"B16007_calc_pctSpanE\"<\/span>\r\n];\r\n<\/code><\/pre>\n<p>Now the script is ready to execute.<\/p>\n<h2>5. Execute the script<\/h2>\n<p>To execute the script, you must hydrate the profile variables with valid inputs. In the case of the visualization profile, you must set <code>$feature<\/code> to a <a href=\"https:\/\/developers.arcgis.com\/javascript\/latest\/api-reference\/esri-Graphic.html\">Graphic<\/a> instance and <code>$view<\/code> to a <a href=\"https:\/\/developers.arcgis.com\/javascript\/latest\/api-reference\/esri-views-MapView.html\">MapView<\/a> instance.<\/p>\n<p>Since I\u2019m creating a scatterplot where each point represents a feature in the view, I need to <a href=\"https:\/\/developers.arcgis.com\/javascript\/latest\/query-filter\/#client-side-queries\">query all features in the view<\/a> and execute the expression for each feature.<\/p>\n<pre><code style=\"padding: 0.5em; color: #333; background: #f8f8f8;\"><span style=\"color: #333; font-weight: bold;\">const<\/span> spanishSpeakersLayerView = <span style=\"color: #333; font-weight: bold;\">await<\/span> view.whenLayerView(spanishSpeakersLayer);\r\n<span style=\"color: #333; font-weight: bold;\">const<\/span> { features } = <span style=\"color: #333; font-weight: bold;\">await<\/span> spanishSpeakersLayerView.queryFeatures();\r\n\r\n<span style=\"color: #333; font-weight: bold;\">const<\/span> chartPoints = features.map( <span style=\"color: #333; font-weight: bold;\">async<\/span> (feature) =&gt; {\r\n  <span style=\"color: #998; font-style: italic;\">\/\/ Execute the Arcade expression for each feature in the layer view<\/span>\r\n  <span style=\"color: #333; font-weight: bold;\">const<\/span> diversityIndex = <span style=\"color: #333; font-weight: bold;\">await<\/span> diversityArcadeExecutor.executeAsync({\r\n    <span style=\"color: #d14;\">\"$feature\"<\/span>: feature,\r\n    <span style=\"color: #d14;\">\"$view\"<\/span>: view\r\n  });\r\n\r\n  <span style=\"color: #333; font-weight: bold;\">const<\/span> backgroundColor = <span style=\"color: #333; font-weight: bold;\">await<\/span> symbolUtils.getDisplayedColor(feature);\r\n  <span style=\"color: #998; font-style: italic;\">\/\/ Return the chart data along with the color used to represent<\/span>\r\n  <span style=\"color: #998; font-style: italic;\">\/\/ the diversity index value in the color variable<\/span>\r\n  <span style=\"color: #333; font-weight: bold;\">return<\/span> {\r\n    data: {\r\n      x: diversityIndex,\r\n      y: feature.attributes.B16007_calc_pctSpanE\r\n    },\r\n    backgroundColor\r\n  }\r\n});\r\n\r\n<span style=\"color: #998; font-style: italic;\">\/\/ Use a Chart API to build a chart from the Arcade results<\/span>\r\n<span style=\"color: #333; font-weight: bold;\">const<\/span> chartDataArray = <span style=\"color: #333; font-weight: bold;\">await<\/span> <span style=\"color: #0086b3;\">Promise<\/span>.all(chartPoints);\r\n<\/code><\/pre>\n<p>The result of the expression (i.e. the diversity index value) is provided to the x axis of the chart in addition to the percentage of the population that speaks Spanish (the chart&#8217;s y axis).<\/p>\n<p>Once the data is processed on the client and provided to the chart, it will render alongside the map view. Also note the color of each point corresponds to the color of the related feature on the map.<\/p>\n"},{"acf_fc_layout":"image","image":{"ID":1690542,"id":1690542,"title":"Screen Shot 2022-08-19 at 9.36.25 AM","filename":"Screen-Shot-2022-08-19-at-9.36.25-AM.png","filesize":273012,"url":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2022\/08\/Screen-Shot-2022-08-19-at-9.36.25-AM.png","link":"https:\/\/www.esri.com\/arcgis-blog\/products\/js-api-arcgis\/developers\/execute-arcade-expressions-on-your-terms\/screen-shot-2022-08-19-at-9-36-25-am","alt":"The language diversity index in this map is calculated with an Arcade expression in the layer's renderer. To display a complimentary chart with this information, you must execute the expression for each data point outside the context of the renderer.","author":"6561","description":"","caption":"The language diversity index in this map is calculated with an Arcade expression in the layer's renderer. To display a complimentary chart with this information, you must execute the expression for each data point outside the context of the renderer.","name":"screen-shot-2022-08-19-at-9-36-25-am","status":"inherit","uploaded_to":1688362,"date":"2022-08-19 16:37:12","modified":"2022-08-19 16:38:44","menu_order":0,"mime_type":"image\/png","type":"image","subtype":"png","icon":"https:\/\/www.esri.com\/arcgis-blog\/wp-includes\/images\/media\/default.png","width":1278,"height":742,"sizes":{"thumbnail":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2022\/08\/Screen-Shot-2022-08-19-at-9.36.25-AM-213x200.png","thumbnail-width":213,"thumbnail-height":200,"medium":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2022\/08\/Screen-Shot-2022-08-19-at-9.36.25-AM.png","medium-width":450,"medium-height":261,"medium_large":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2022\/08\/Screen-Shot-2022-08-19-at-9.36.25-AM.png","medium_large-width":768,"medium_large-height":446,"large":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2022\/08\/Screen-Shot-2022-08-19-at-9.36.25-AM.png","large-width":1278,"large-height":742,"1536x1536":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2022\/08\/Screen-Shot-2022-08-19-at-9.36.25-AM.png","1536x1536-width":1278,"1536x1536-height":742,"2048x2048":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2022\/08\/Screen-Shot-2022-08-19-at-9.36.25-AM.png","2048x2048-width":1278,"2048x2048-height":742,"card_image":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2022\/08\/Screen-Shot-2022-08-19-at-9.36.25-AM-801x465.png","card_image-width":801,"card_image-height":465,"wide_image":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2022\/08\/Screen-Shot-2022-08-19-at-9.36.25-AM.png","wide_image-width":1278,"wide_image-height":742}},"image_position":"center","orientation":"horizontal","hyperlink":"https:\/\/developers.arcgis.com\/javascript\/latest\/sample-code\/arcade-execute-chart\/"},{"acf_fc_layout":"content","content":"<h2>Conclusion<\/h2>\n<p>This was just one example of how you can use the ArcadeExecutor to execute Arcade expressions already defined in web maps in the context of an ArcGIS API for JavaScript web application. You could similarly display the results in a custom web component or as input to another analytical process.<\/p>\n<p>Check out the <a href=\"https:\/\/developers.arcgis.com\/javascript\/latest\/sample-code\/arcade-execute-chart\/\">Execute Arcade for a custom chart<\/a> sample to review the full app code and explore the data on your own.<\/p>\n"}],"authors":[{"ID":6561,"user_firstname":"Kristian","user_lastname":"Ekenes","nickname":"Kristian Ekenes","user_nicename":"kekenes","display_name":"Kristian Ekenes","user_email":"KEkenes@esri.com","user_url":"https:\/\/github.com\/ekenes","user_registered":"2018-03-02 00:18:32","user_description":"Kristian Ekenes is a Principal Product Engineer at Esri specializing in data visualization on the web. He works on the ArcGIS Maps SDK for JavaScript, ArcGIS Arcade, and Map Viewer in ArcGIS Online. Kristian's work focuses on researching and developing new and innovative data visualization capabilities of geospatial data in web maps, Arcade integration in web maps, and applications of generative AI assistants in web maps. Prior to joining Esri, he worked as a GIS Specialist for an environmental consulting company. Kristian has degrees from Brigham Young University and Arizona State University.","user_avatar":"<img data-del=\"avatar\" src='https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2021\/10\/ekenes-zurich-213x200.png' class='avatar pp-user-avatar avatar-96 photo ' height='96' width='96'\/>"}],"related_articles":[{"ID":1683632,"post_author":"6561","post_date":"2022-08-16 09:00:52","post_date_gmt":"2022-08-16 16:00:52","post_content":"","post_title":"I\u2019m a developer. Do I really need Arcade?","post_excerpt":"","post_status":"publish","comment_status":"open","ping_status":"closed","post_password":"","post_name":"im-a-developer-do-i-really-need-arcade","to_ping":"","pinged":"","post_modified":"2024-10-31 23:59:49","post_modified_gmt":"2024-11-01 06:59:49","post_content_filtered":"","post_parent":0,"guid":"https:\/\/www.esri.com\/arcgis-blog\/?post_type=blog&#038;p=1683632","menu_order":0,"post_type":"blog","post_mime_type":"","comment_count":"0","filter":"raw"},{"ID":1546922,"post_author":"6561","post_date":"2022-04-21 10:06:41","post_date_gmt":"2022-04-21 17:06:41","post_content":"","post_title":"Create a diversity map with Arcade","post_excerpt":"","post_status":"publish","comment_status":"open","ping_status":"closed","post_password":"","post_name":"create-a-diversity-index-with-arcade","to_ping":"","pinged":"","post_modified":"2024-11-01 00:00:13","post_modified_gmt":"2024-11-01 07:00:13","post_content_filtered":"","post_parent":0,"guid":"https:\/\/www.esri.com\/arcgis-blog\/?post_type=blog&#038;p=1546922","menu_order":0,"post_type":"blog","post_mime_type":"","comment_count":"0","filter":"raw"},{"ID":74711,"post_author":"6981","post_date":"2016-12-19 04:35:28","post_date_gmt":"2016-12-19 04:35:28","post_content":"","post_title":"Introducing Arcade","post_excerpt":"","post_status":"publish","comment_status":"closed","ping_status":"closed","post_password":"","post_name":"introducing-arcade","to_ping":"","pinged":"","post_modified":"2024-11-11 12:40:39","post_modified_gmt":"2024-11-11 20:40:39","post_content_filtered":"","post_parent":0,"guid":"http:\/\/www.esri.com\/arcgis-blog\/products\/product\/uncategorized\/introducing-arcade\/","menu_order":0,"post_type":"blog","post_mime_type":"","comment_count":"0","filter":"raw"}],"card_image":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2022\/08\/card.jpg","wide_image":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2022\/08\/banner-2.jpg"},"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v25.9 (Yoast SEO v25.9) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Execute Arcade expressions on your terms<\/title>\n<meta name=\"description\" content=\"Have you ever wanted to execute an Arcade script outside of a pre-defined Arcade profile? Now you can.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.esri.com\/arcgis-blog\/products\/js-api-arcgis\/developers\/execute-arcade-expressions-on-your-terms\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Execute Arcade expressions on your terms\" \/>\n<meta property=\"og:description\" content=\"Have you ever wanted to execute an Arcade script outside of a pre-defined Arcade profile? Now you can.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.esri.com\/arcgis-blog\/products\/js-api-arcgis\/developers\/execute-arcade-expressions-on-your-terms\" \/>\n<meta property=\"og:site_name\" content=\"ArcGIS Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/esrigis\/\" \/>\n<meta property=\"article:modified_time\" content=\"2024-11-01T06:59:37+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.esri.com\/arcgis-blog\/wp-content\/uploads\/2022\/08\/card.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"826\" \/>\n\t<meta property=\"og:image:height\" content=\"465\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:site\" content=\"@ESRI\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":[\"Article\",\"BlogPosting\"],\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/products\/js-api-arcgis\/developers\/execute-arcade-expressions-on-your-terms#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/products\/js-api-arcgis\/developers\/execute-arcade-expressions-on-your-terms\"},\"author\":{\"name\":\"Kristian Ekenes\",\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/#\/schema\/person\/5469f723fbfb78138efbb1da56e6aa9b\"},\"headline\":\"Execute Arcade expressions on your terms\",\"datePublished\":\"2022-08-22T16:30:37+00:00\",\"dateModified\":\"2024-11-01T06:59:37+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/products\/js-api-arcgis\/developers\/execute-arcade-expressions-on-your-terms\"},\"wordCount\":6,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/#organization\"},\"keywords\":[\"arcade\"],\"articleSection\":[\"Arcade\",\"Developers\",\"Mapping\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.esri.com\/arcgis-blog\/products\/js-api-arcgis\/developers\/execute-arcade-expressions-on-your-terms#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/products\/js-api-arcgis\/developers\/execute-arcade-expressions-on-your-terms\",\"url\":\"https:\/\/www.esri.com\/arcgis-blog\/products\/js-api-arcgis\/developers\/execute-arcade-expressions-on-your-terms\",\"name\":\"Execute Arcade expressions on your terms\",\"isPartOf\":{\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/#website\"},\"datePublished\":\"2022-08-22T16:30:37+00:00\",\"dateModified\":\"2024-11-01T06:59:37+00:00\",\"description\":\"Have you ever wanted to execute an Arcade script outside of a pre-defined Arcade profile? Now you can.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/products\/js-api-arcgis\/developers\/execute-arcade-expressions-on-your-terms#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.esri.com\/arcgis-blog\/products\/js-api-arcgis\/developers\/execute-arcade-expressions-on-your-terms\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/products\/js-api-arcgis\/developers\/execute-arcade-expressions-on-your-terms#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.esri.com\/arcgis-blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Execute Arcade expressions on your terms\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/#website\",\"url\":\"https:\/\/www.esri.com\/arcgis-blog\/\",\"name\":\"ArcGIS Blog\",\"description\":\"Get insider info from Esri product teams\",\"publisher\":{\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.esri.com\/arcgis-blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/#organization\",\"name\":\"Esri\",\"url\":\"https:\/\/www.esri.com\/arcgis-blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2018\/04\/Esri.png\",\"contentUrl\":\"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2018\/04\/Esri.png\",\"width\":400,\"height\":400,\"caption\":\"Esri\"},\"image\":{\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/esrigis\/\",\"https:\/\/x.com\/ESRI\",\"https:\/\/www.linkedin.com\/company\/5311\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/#\/schema\/person\/5469f723fbfb78138efbb1da56e6aa9b\",\"name\":\"Kristian Ekenes\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2021\/10\/ekenes-zurich-213x200.png\",\"contentUrl\":\"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2021\/10\/ekenes-zurich-213x200.png\",\"caption\":\"Kristian Ekenes\"},\"description\":\"Kristian Ekenes is a Principal Product Engineer at Esri specializing in data visualization on the web. He works on the ArcGIS Maps SDK for JavaScript, ArcGIS Arcade, and Map Viewer in ArcGIS Online. Kristian's work focuses on researching and developing new and innovative data visualization capabilities of geospatial data in web maps, Arcade integration in web maps, and applications of generative AI assistants in web maps. Prior to joining Esri, he worked as a GIS Specialist for an environmental consulting company. Kristian has degrees from Brigham Young University and Arizona State University.\",\"sameAs\":[\"https:\/\/github.com\/ekenes\",\"https:\/\/www.linkedin.com\/in\/kristian-ekenes\/\",\"https:\/\/x.com\/kekenes\"],\"gender\":\"male\",\"jobTitle\":\"Principal Product Engineer\",\"worksFor\":\"Esri\",\"url\":\"https:\/\/www.esri.com\/arcgis-blog\/author\/kekenes\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Execute Arcade expressions on your terms","description":"Have you ever wanted to execute an Arcade script outside of a pre-defined Arcade profile? Now you can.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.esri.com\/arcgis-blog\/products\/js-api-arcgis\/developers\/execute-arcade-expressions-on-your-terms","og_locale":"en_US","og_type":"article","og_title":"Execute Arcade expressions on your terms","og_description":"Have you ever wanted to execute an Arcade script outside of a pre-defined Arcade profile? Now you can.","og_url":"https:\/\/www.esri.com\/arcgis-blog\/products\/js-api-arcgis\/developers\/execute-arcade-expressions-on-your-terms","og_site_name":"ArcGIS Blog","article_publisher":"https:\/\/www.facebook.com\/esrigis\/","article_modified_time":"2024-11-01T06:59:37+00:00","og_image":[{"width":826,"height":465,"url":"https:\/\/www.esri.com\/arcgis-blog\/wp-content\/uploads\/2022\/08\/card.jpg","type":"image\/jpeg"}],"twitter_card":"summary_large_image","twitter_site":"@ESRI","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":["Article","BlogPosting"],"@id":"https:\/\/www.esri.com\/arcgis-blog\/products\/js-api-arcgis\/developers\/execute-arcade-expressions-on-your-terms#article","isPartOf":{"@id":"https:\/\/www.esri.com\/arcgis-blog\/products\/js-api-arcgis\/developers\/execute-arcade-expressions-on-your-terms"},"author":{"name":"Kristian Ekenes","@id":"https:\/\/www.esri.com\/arcgis-blog\/#\/schema\/person\/5469f723fbfb78138efbb1da56e6aa9b"},"headline":"Execute Arcade expressions on your terms","datePublished":"2022-08-22T16:30:37+00:00","dateModified":"2024-11-01T06:59:37+00:00","mainEntityOfPage":{"@id":"https:\/\/www.esri.com\/arcgis-blog\/products\/js-api-arcgis\/developers\/execute-arcade-expressions-on-your-terms"},"wordCount":6,"commentCount":0,"publisher":{"@id":"https:\/\/www.esri.com\/arcgis-blog\/#organization"},"keywords":["arcade"],"articleSection":["Arcade","Developers","Mapping"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.esri.com\/arcgis-blog\/products\/js-api-arcgis\/developers\/execute-arcade-expressions-on-your-terms#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.esri.com\/arcgis-blog\/products\/js-api-arcgis\/developers\/execute-arcade-expressions-on-your-terms","url":"https:\/\/www.esri.com\/arcgis-blog\/products\/js-api-arcgis\/developers\/execute-arcade-expressions-on-your-terms","name":"Execute Arcade expressions on your terms","isPartOf":{"@id":"https:\/\/www.esri.com\/arcgis-blog\/#website"},"datePublished":"2022-08-22T16:30:37+00:00","dateModified":"2024-11-01T06:59:37+00:00","description":"Have you ever wanted to execute an Arcade script outside of a pre-defined Arcade profile? Now you can.","breadcrumb":{"@id":"https:\/\/www.esri.com\/arcgis-blog\/products\/js-api-arcgis\/developers\/execute-arcade-expressions-on-your-terms#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.esri.com\/arcgis-blog\/products\/js-api-arcgis\/developers\/execute-arcade-expressions-on-your-terms"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.esri.com\/arcgis-blog\/products\/js-api-arcgis\/developers\/execute-arcade-expressions-on-your-terms#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.esri.com\/arcgis-blog\/"},{"@type":"ListItem","position":2,"name":"Execute Arcade expressions on your terms"}]},{"@type":"WebSite","@id":"https:\/\/www.esri.com\/arcgis-blog\/#website","url":"https:\/\/www.esri.com\/arcgis-blog\/","name":"ArcGIS Blog","description":"Get insider info from Esri product teams","publisher":{"@id":"https:\/\/www.esri.com\/arcgis-blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.esri.com\/arcgis-blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.esri.com\/arcgis-blog\/#organization","name":"Esri","url":"https:\/\/www.esri.com\/arcgis-blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.esri.com\/arcgis-blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2018\/04\/Esri.png","contentUrl":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2018\/04\/Esri.png","width":400,"height":400,"caption":"Esri"},"image":{"@id":"https:\/\/www.esri.com\/arcgis-blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/esrigis\/","https:\/\/x.com\/ESRI","https:\/\/www.linkedin.com\/company\/5311\/"]},{"@type":"Person","@id":"https:\/\/www.esri.com\/arcgis-blog\/#\/schema\/person\/5469f723fbfb78138efbb1da56e6aa9b","name":"Kristian Ekenes","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.esri.com\/arcgis-blog\/#\/schema\/person\/image\/","url":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2021\/10\/ekenes-zurich-213x200.png","contentUrl":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2021\/10\/ekenes-zurich-213x200.png","caption":"Kristian Ekenes"},"description":"Kristian Ekenes is a Principal Product Engineer at Esri specializing in data visualization on the web. He works on the ArcGIS Maps SDK for JavaScript, ArcGIS Arcade, and Map Viewer in ArcGIS Online. Kristian's work focuses on researching and developing new and innovative data visualization capabilities of geospatial data in web maps, Arcade integration in web maps, and applications of generative AI assistants in web maps. Prior to joining Esri, he worked as a GIS Specialist for an environmental consulting company. Kristian has degrees from Brigham Young University and Arizona State University.","sameAs":["https:\/\/github.com\/ekenes","https:\/\/www.linkedin.com\/in\/kristian-ekenes\/","https:\/\/x.com\/kekenes"],"gender":"male","jobTitle":"Principal Product Engineer","worksFor":"Esri","url":"https:\/\/www.esri.com\/arcgis-blog\/author\/kekenes"}]}},"text_date":"August 22, 2022","author_name":"Kristian Ekenes","author_page":"https:\/\/www.esri.com\/arcgis-blog\/author\/kekenes","custom_image":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2022\/08\/banner-2.jpg","primary_product":"ArcGIS Maps SDK for JavaScript","tag_data":[{"term_id":32551,"name":"arcade","slug":"arcade","term_group":0,"term_taxonomy_id":32551,"taxonomy":"post_tag","description":"","parent":0,"count":113,"filter":"raw"}],"category_data":[{"term_id":777102,"name":"Arcade","slug":"arcade","term_group":0,"term_taxonomy_id":777102,"taxonomy":"category","description":"","parent":0,"count":98,"filter":"raw"},{"term_id":738191,"name":"Developers","slug":"developers","term_group":0,"term_taxonomy_id":738191,"taxonomy":"category","description":"","parent":0,"count":420,"filter":"raw"},{"term_id":22941,"name":"Mapping","slug":"mapping","term_group":0,"term_taxonomy_id":22941,"taxonomy":"category","description":"","parent":0,"count":2683,"filter":"raw"}],"product_data":[{"term_id":761642,"name":"ArcGIS Location Platform","slug":"platform","term_group":0,"term_taxonomy_id":761642,"taxonomy":"product","description":"","parent":36601,"count":213,"filter":"raw"},{"term_id":36831,"name":"ArcGIS Maps SDK for JavaScript","slug":"js-api-arcgis","term_group":0,"term_taxonomy_id":36831,"taxonomy":"product","description":"","parent":36601,"count":361,"filter":"raw"},{"term_id":763892,"name":"ArcGIS Runtime SDKs","slug":"runtime-sdk","term_group":0,"term_taxonomy_id":763892,"taxonomy":"product","description":"","parent":756692,"count":20,"filter":"raw"},{"term_id":36601,"name":"Developers","slug":"developers","term_group":0,"term_taxonomy_id":36601,"taxonomy":"product","description":"","parent":0,"count":761,"filter":"raw"}],"primary_product_link":"https:\/\/www.esri.com\/arcgis-blog\/?s=#&products=js-api-arcgis","_links":{"self":[{"href":"https:\/\/www.esri.com\/arcgis-blog\/wp-json\/wp\/v2\/blog\/1688362","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.esri.com\/arcgis-blog\/wp-json\/wp\/v2\/blog"}],"about":[{"href":"https:\/\/www.esri.com\/arcgis-blog\/wp-json\/wp\/v2\/types\/blog"}],"author":[{"embeddable":true,"href":"https:\/\/www.esri.com\/arcgis-blog\/wp-json\/wp\/v2\/users\/6561"}],"replies":[{"embeddable":true,"href":"https:\/\/www.esri.com\/arcgis-blog\/wp-json\/wp\/v2\/comments?post=1688362"}],"version-history":[{"count":0,"href":"https:\/\/www.esri.com\/arcgis-blog\/wp-json\/wp\/v2\/blog\/1688362\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.esri.com\/arcgis-blog\/wp-json\/wp\/v2\/media?parent=1688362"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.esri.com\/arcgis-blog\/wp-json\/wp\/v2\/categories?post=1688362"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.esri.com\/arcgis-blog\/wp-json\/wp\/v2\/tags?post=1688362"},{"taxonomy":"industry","embeddable":true,"href":"https:\/\/www.esri.com\/arcgis-blog\/wp-json\/wp\/v2\/industry?post=1688362"},{"taxonomy":"product","embeddable":true,"href":"https:\/\/www.esri.com\/arcgis-blog\/wp-json\/wp\/v2\/product?post=1688362"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}