{"id":1562,"date":"2026-03-20T10:33:21","date_gmt":"2026-03-20T10:33:21","guid":{"rendered":"https:\/\/onesystemcrm.com\/help\/?post_type=docs&#038;p=1562"},"modified":"2026-03-20T10:33:21","modified_gmt":"2026-03-20T10:33:21","password":"","slug":"workflow-action-custom-code","status":"publish","type":"docs","link":"https:\/\/onesystemcrm.com\/help\/docs\/workflow-action-custom-code\/","title":{"rendered":"Workflow Action &#8211; Custom Code"},"content":{"rendered":"<h2 id=\"Overview\" dir=\"ltr\" data-identifyelement=\"468\">Overview<\/h2>\n<p>The\u00a0<strong>Custom Code<\/strong> action allows you to extend your workflow\u2019s functionality by writing and executing custom JavaScript code. You can include properties from previous steps, perform operations, and return the output to be used in subsequent steps.<\/p>\n<h2 id=\"Action-Name\" dir=\"ltr\" data-identifyelement=\"468\">Action Name<\/h2>\n<p id=\"-2\" dir=\"ltr\" data-identifyelement=\"468\"><strong>Custom Code<\/strong><\/p>\n<h2 id=\"Action-Description\" dir=\"ltr\" data-identifyelement=\"468\">Action Description<\/h2>\n<p id=\"-4\" dir=\"ltr\" data-identifyelement=\"468\">The\u00a0<strong>Custom Code<\/strong>\u00a0action enables the execution of JavaScript code within a workflow, allowing users to extend the system\u2019s functionality. This action can process data and return output that can be used in the workflow\u2019s subsequent steps.<\/p>\n<h2 id=\"Action-Details\" dir=\"ltr\" data-identifyelement=\"468\">Action Details<\/h2>\n<p dir=\"ltr\" data-identifyelement=\"468\"><img decoding=\"async\" class=\"fr-fic fr-fil fr-dib fr-bordered fw-lightbox-img\" src=\"https:\/\/s3.amazonaws.com\/cdn.freshdesk.com\/data\/helpdesk\/attachments\/production\/155032467316\/original\/J_XDJ_paKZxPI-1e39hRdh68vOEr0s-dbQ.png?1725819732\" data-attachment=\"[object Object]\" data-id=\"155032467316\" data-index=\"0\" \/><\/p>\n<h3><strong>How to Configure<\/strong><\/h3>\n<ol>\n<li><strong>Action Name:<\/strong>\u00a0Give your custom code step a name that reflects its purpose.<\/li>\n<li><strong>Language:<\/strong>\u00a0By default, this is set to JavaScript. Currently, no other languages are supported.<\/li>\n<li><strong>Property to Include in Code:<\/strong>\n<ul>\n<li>Add key-value pairs where the key will be used in your code, and the value can either be hardcoded or dynamically mapped from previous workflow steps.<\/li>\n<li>Use these key-value pairs within the code by referencing\u00a0<code>inputData.&lt;key&gt;<\/code>. For example, if the key is\u00a0<code>number1<\/code>, you can access it in the code as\u00a0<code>inputData.number1<\/code>.<\/li>\n<\/ul>\n<\/li>\n<li><strong>Code:<\/strong>\n<ul>\n<li>Write JavaScript code to process the values mapped in the previous step.<\/li>\n<li dir=\"ltr\">Ensure the output is in the form of a JavaScript object or array of objects. Example:\u00a0<code>output = { result: sum }<\/code>.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<table dir=\"ltr\" border=\"1\" cellspacing=\"0\" cellpadding=\"0\" data-sheets-baot=\"1\" data-sheets-root=\"1\">\n<colgroup>\n<col width=\"100\" \/>\n<col width=\"506\" \/>\n<col width=\"119\" \/><\/colgroup>\n<tbody>\n<tr>\n<td dir=\"ltr\">Field Name<\/td>\n<td>Description<\/td>\n<td>Mandatory<\/td>\n<\/tr>\n<tr>\n<td>Action Name<\/td>\n<td>The name of the action that will be displayed in the workflow.<\/td>\n<td>Yes<\/td>\n<\/tr>\n<tr>\n<td>Language<\/td>\n<td>The programming language used for the custom code (default is JavaScript).<\/td>\n<td>Yes<\/td>\n<\/tr>\n<tr>\n<td>Property To Include In Code<\/td>\n<td>Fields to be used within the code, mapped from previous steps. Use inputData.keyName to access the values within the code.<\/td>\n<td>Yes<\/td>\n<\/tr>\n<tr>\n<td>Code<\/td>\n<td>JavaScript code to perform the desired operation. The output should be a JavaScript object.<\/td>\n<td>Yes<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2 dir=\"ltr\" data-identifyelement=\"468\"><\/h2>\n<h2 id=\"Example\" dir=\"ltr\" data-identifyelement=\"468\">Example<\/h2>\n<div class=\"dark bg-gray-950 contain-inline-size rounded-md border-[0.5px] border-token-border-medium relative\">\n<div class=\"flex items-center text-token-text-secondary bg-token-main-surface-secondary px-4 py-2 text-xs font-sans justify-between rounded-t-md h-9\">javascript<\/div>\n<div class=\"sticky top-9 md:top-[5.75rem]\">\n<div class=\"absolute bottom-0 right-2 flex h-9 items-center\">\n<div class=\"flex items-center rounded bg-token-main-surface-secondary px-2 font-sans text-xs text-token-text-secondary\"><span data-state=\"closed\">Copy code<\/span><\/div>\n<\/div>\n<\/div>\n<div class=\"overflow-y-auto p-4\" dir=\"ltr\"><code class=\"!whitespace-pre hljs  language-javascript\"><span class=\"token comment\">\/\/ This is wrapped in an async function<\/span>\u00a0<span class=\"token keyword\">const<\/span>\u00a0sum\u00a0<span class=\"token operator\">=<\/span>\u00a0inputData<span class=\"token punctuation\">.<\/span>number1\u00a0<span class=\"token operator\">+<\/span>\u00a0inputData<span class=\"token punctuation\">.<\/span>number2<span class=\"token punctuation\">;<\/span>\u00a0<span class=\"token comment\">\/\/ Return the result as a JavaScript object<\/span>\u00a0output\u00a0<span class=\"token operator\">=<\/span>\u00a0<span class=\"token punctuation\">{<\/span>\u00a0result<span class=\"token operator\">:<\/span>\u00a0sum\u00a0<span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">;<\/span><\/code><\/div>\n<\/div>\n<p>This example adds two numbers from the mapped properties\u00a0<code>number1<\/code>\u00a0and\u00a0<code>number2<\/code>\u00a0and outputs their sum.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Overview The\u00a0Custom Code action allows you to extend your workflow\u2019s functionality by writing and executing custom JavaScript code. You can [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","template":"","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"default","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"set","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"doc_category":[76],"doc_tag":[],"class_list":["post-1562","docs","type-docs","status-publish","hentry","doc_category-integrations-workflow-actions"],"year_month":"2026-12","word_count":327,"total_views":"147","reactions":{"happy":"0","normal":"0","sad":"0"},"author_info":{"name":"usamasaeed219","author_nicename":"usamasaeed219","author_url":"https:\/\/onesystemcrm.com\/help\/author\/usamasaeed219\/"},"doc_category_info":[{"term_name":"Integrations Workflow Actions","term_url":"https:\/\/onesystemcrm.com\/help\/docs-category\/integrations-workflow-actions\/"}],"doc_tag_info":[],"knowledge_base_info":[],"knowledge_base_slug":[],"_links":{"self":[{"href":"https:\/\/onesystemcrm.com\/help\/wp-json\/wp\/v2\/docs\/1562","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/onesystemcrm.com\/help\/wp-json\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/onesystemcrm.com\/help\/wp-json\/wp\/v2\/types\/docs"}],"author":[{"embeddable":true,"href":"https:\/\/onesystemcrm.com\/help\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/onesystemcrm.com\/help\/wp-json\/wp\/v2\/comments?post=1562"}],"version-history":[{"count":1,"href":"https:\/\/onesystemcrm.com\/help\/wp-json\/wp\/v2\/docs\/1562\/revisions"}],"predecessor-version":[{"id":1563,"href":"https:\/\/onesystemcrm.com\/help\/wp-json\/wp\/v2\/docs\/1562\/revisions\/1563"}],"wp:attachment":[{"href":"https:\/\/onesystemcrm.com\/help\/wp-json\/wp\/v2\/media?parent=1562"}],"wp:term":[{"taxonomy":"doc_category","embeddable":true,"href":"https:\/\/onesystemcrm.com\/help\/wp-json\/wp\/v2\/doc_category?post=1562"},{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/onesystemcrm.com\/help\/wp-json\/wp\/v2\/doc_tag?post=1562"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}