{"id":3934,"date":"2023-09-22T07:20:35","date_gmt":"2023-09-22T06:20:35","guid":{"rendered":"https:\/\/help.expertsender.com\/?post_type=es&#038;p=3934"},"modified":"2024-03-19T13:25:36","modified_gmt":"2024-03-19T12:25:36","slug":"setting-workflow-data-field-value","status":"publish","type":"es","link":"https:\/\/help.expertsender.com\/pl\/emp\/dynamic-content\/handling-workflow-data-fields\/setting-workflow-data-field-value\/","title":{"rendered":"Setting workflow data field value"},"content":{"rendered":"\n<p>Dynamic Content can be used to automatically change value of data field in workflow for currently processed subscriber, using SetWorkflowDataField method.<\/p>\n\n\n\n<p>Note that this method can be used only inside workflows (workflow messages, api call element, execute code element).<\/p>\n\n\n\n<p>Method signature:<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#babed8;--cbp-line-number-width:8.4375px;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span role=\"button\" tabindex=\"0\" data-code=\"SetWorkflowDataField(name, value)\" style=\"color:#babed8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg  style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M4.5 12.75l6 6 9-13.5\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6\"><\/path><\/svg><\/span><pre class=\"shiki material-theme-palenight\" style=\"background-color: #292D3E\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #82AAFF\">SetWorkflowDataField<\/span><span style=\"color: #BABED8\">(name<\/span><span style=\"color: #89DDFF\">,<\/span><span style=\"color: #BABED8\"> value)<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>name parameter is name of data field.<\/p>\n\n\n\n<p>value parameter is new value of data field which will be set for subscriber.<\/p>\n\n\n\n<p>Method always returns empty string.<\/p>\n\n\n\n<p>value parameter will accept any object, but it is important to set appropriate value, depending on data field type. See examples below for different types of data fields.<\/p>\n\n\n\n<p>Boolean properties:<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#babed8;--cbp-line-number-width:8.4375px;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span role=\"button\" tabindex=\"0\" data-code=\"${SetWorkflowDataField('some_boolean', true)}\n${SetWorkflowDataField('some_boolean', false)}\" style=\"color:#babed8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg  style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M4.5 12.75l6 6 9-13.5\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6\"><\/path><\/svg><\/span><pre class=\"shiki material-theme-palenight\" style=\"background-color: #292D3E\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #BABED8\">$<\/span><span style=\"color: #89DDFF\">{<\/span><span style=\"color: #82AAFF\">SetWorkflowDataField<\/span><span style=\"color: #F07178\">(<\/span><span style=\"color: #89DDFF\">&#39;<\/span><span style=\"color: #C3E88D\">some_boolean<\/span><span style=\"color: #89DDFF\">&#39;<\/span><span style=\"color: #89DDFF\">,<\/span><span style=\"color: #F07178\"> <\/span><span style=\"color: #FF9CAC\">true<\/span><span style=\"color: #F07178\">)<\/span><span style=\"color: #89DDFF\">}<\/span><\/span>\n<span class=\"line\"><span style=\"color: #BABED8\">$<\/span><span style=\"color: #89DDFF\">{<\/span><span style=\"color: #82AAFF\">SetWorkflowDataField<\/span><span style=\"color: #F07178\">(<\/span><span style=\"color: #89DDFF\">&#39;<\/span><span style=\"color: #C3E88D\">some_boolean<\/span><span style=\"color: #89DDFF\">&#39;<\/span><span style=\"color: #89DDFF\">,<\/span><span style=\"color: #F07178\"> <\/span><span style=\"color: #FF9CAC\">false<\/span><span style=\"color: #F07178\">)<\/span><span style=\"color: #89DDFF\">}<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>Text properties:<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#babed8;--cbp-line-number-width:8.4375px;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span role=\"button\" tabindex=\"0\" data-code=\"${SetWorkflowDataField('some_text', 'foobar')}\" style=\"color:#babed8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg  style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M4.5 12.75l6 6 9-13.5\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6\"><\/path><\/svg><\/span><pre class=\"shiki material-theme-palenight\" style=\"background-color: #292D3E\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #BABED8\">$<\/span><span style=\"color: #89DDFF\">{<\/span><span style=\"color: #82AAFF\">SetWorkflowDataField<\/span><span style=\"color: #F07178\">(<\/span><span style=\"color: #89DDFF\">&#39;<\/span><span style=\"color: #C3E88D\">some_text<\/span><span style=\"color: #89DDFF\">&#39;<\/span><span style=\"color: #89DDFF\">,<\/span><span style=\"color: #F07178\"> <\/span><span style=\"color: #89DDFF\">&#39;<\/span><span style=\"color: #C3E88D\">foobar<\/span><span style=\"color: #89DDFF\">&#39;<\/span><span style=\"color: #F07178\">)<\/span><span style=\"color: #89DDFF\">}<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>Number properties:<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#babed8;--cbp-line-number-width:8.4375px;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span role=\"button\" tabindex=\"0\" data-code=\"${SetWorkflowDataField('some_number', 123)}\" style=\"color:#babed8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg  style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M4.5 12.75l6 6 9-13.5\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6\"><\/path><\/svg><\/span><pre class=\"shiki material-theme-palenight\" style=\"background-color: #292D3E\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #BABED8\">$<\/span><span style=\"color: #89DDFF\">{<\/span><span style=\"color: #82AAFF\">SetWorkflowDataField<\/span><span style=\"color: #F07178\">(<\/span><span style=\"color: #89DDFF\">&#39;<\/span><span style=\"color: #C3E88D\">some_number<\/span><span style=\"color: #89DDFF\">&#39;<\/span><span style=\"color: #89DDFF\">,<\/span><span style=\"color: #F07178\"> <\/span><span style=\"color: #F78C6C\">123<\/span><span style=\"color: #F07178\">)<\/span><span style=\"color: #89DDFF\">}<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>Date and DateTime properties:<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#babed8;--cbp-line-number-width:8.4375px;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span role=\"button\" tabindex=\"0\" data-code=\"${SetWorkflowDataField('some_date', '2013-12-02')}\n${SetWorkflowDataField('some_datetime', '2013-12-02 10:15:00')}\n${SetWorkflowDataField('some_date', new System.DateTime(2013, 12, 2).Date)}\n${SetWorkflowDataField('some_datetime', new System.DateTime(2013, 12, 2, 10, 15, 0))}\" style=\"color:#babed8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg  style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M4.5 12.75l6 6 9-13.5\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6\"><\/path><\/svg><\/span><pre class=\"shiki material-theme-palenight\" style=\"background-color: #292D3E\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #BABED8\">$<\/span><span style=\"color: #89DDFF\">{<\/span><span style=\"color: #82AAFF\">SetWorkflowDataField<\/span><span style=\"color: #F07178\">(<\/span><span style=\"color: #89DDFF\">&#39;<\/span><span style=\"color: #C3E88D\">some_date<\/span><span style=\"color: #89DDFF\">&#39;<\/span><span style=\"color: #89DDFF\">,<\/span><span style=\"color: #F07178\"> <\/span><span style=\"color: #89DDFF\">&#39;<\/span><span style=\"color: #C3E88D\">2013-12-02<\/span><span style=\"color: #89DDFF\">&#39;<\/span><span style=\"color: #F07178\">)<\/span><span style=\"color: #89DDFF\">}<\/span><\/span>\n<span class=\"line\"><span style=\"color: #BABED8\">$<\/span><span style=\"color: #89DDFF\">{<\/span><span style=\"color: #82AAFF\">SetWorkflowDataField<\/span><span style=\"color: #F07178\">(<\/span><span style=\"color: #89DDFF\">&#39;<\/span><span style=\"color: #C3E88D\">some_datetime<\/span><span style=\"color: #89DDFF\">&#39;<\/span><span style=\"color: #89DDFF\">,<\/span><span style=\"color: #F07178\"> <\/span><span style=\"color: #89DDFF\">&#39;<\/span><span style=\"color: #C3E88D\">2013-12-02 10:15:00<\/span><span style=\"color: #89DDFF\">&#39;<\/span><span style=\"color: #F07178\">)<\/span><span style=\"color: #89DDFF\">}<\/span><\/span>\n<span class=\"line\"><span style=\"color: #BABED8\">$<\/span><span style=\"color: #89DDFF\">{<\/span><span style=\"color: #82AAFF\">SetWorkflowDataField<\/span><span style=\"color: #F07178\">(<\/span><span style=\"color: #89DDFF\">&#39;<\/span><span style=\"color: #C3E88D\">some_date<\/span><span style=\"color: #89DDFF\">&#39;<\/span><span style=\"color: #89DDFF\">,<\/span><span style=\"color: #F07178\"> <\/span><span style=\"color: #89DDFF\">new<\/span><span style=\"color: #F07178\"> <\/span><span style=\"color: #BABED8\">System<\/span><span style=\"color: #89DDFF\">.<\/span><span style=\"color: #82AAFF\">DateTime<\/span><span style=\"color: #F07178\">(<\/span><span style=\"color: #F78C6C\">2013<\/span><span style=\"color: #89DDFF\">,<\/span><span style=\"color: #F07178\"> <\/span><span style=\"color: #F78C6C\">12<\/span><span style=\"color: #89DDFF\">,<\/span><span style=\"color: #F07178\"> <\/span><span style=\"color: #F78C6C\">2<\/span><span style=\"color: #F07178\">)<\/span><span style=\"color: #89DDFF\">.<\/span><span style=\"color: #BABED8\">Date<\/span><span style=\"color: #F07178\">)<\/span><span style=\"color: #89DDFF\">}<\/span><\/span>\n<span class=\"line\"><span style=\"color: #BABED8\">$<\/span><span style=\"color: #89DDFF\">{<\/span><span style=\"color: #82AAFF\">SetWorkflowDataField<\/span><span style=\"color: #F07178\">(<\/span><span style=\"color: #89DDFF\">&#39;<\/span><span style=\"color: #C3E88D\">some_datetime<\/span><span style=\"color: #89DDFF\">&#39;<\/span><span style=\"color: #89DDFF\">,<\/span><span style=\"color: #F07178\"> <\/span><span style=\"color: #89DDFF\">new<\/span><span style=\"color: #F07178\"> <\/span><span style=\"color: #BABED8\">System<\/span><span style=\"color: #89DDFF\">.<\/span><span style=\"color: #82AAFF\">DateTime<\/span><span style=\"color: #F07178\">(<\/span><span style=\"color: #F78C6C\">2013<\/span><span style=\"color: #89DDFF\">,<\/span><span style=\"color: #F07178\"> <\/span><span style=\"color: #F78C6C\">12<\/span><span style=\"color: #89DDFF\">,<\/span><span style=\"color: #F07178\"> <\/span><span style=\"color: #F78C6C\">2<\/span><span style=\"color: #89DDFF\">,<\/span><span style=\"color: #F07178\"> <\/span><span style=\"color: #F78C6C\">10<\/span><span style=\"color: #89DDFF\">,<\/span><span style=\"color: #F07178\"> <\/span><span style=\"color: #F78C6C\">15<\/span><span style=\"color: #89DDFF\">,<\/span><span style=\"color: #F07178\"> <\/span><span style=\"color: #F78C6C\">0<\/span><span style=\"color: #F07178\">))<\/span><span style=\"color: #89DDFF\">}<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>NOTE: For convenience, it is possible to provide date\/datetime as a string, but it is required to use sortable (ISO) format: YYYY-MM-DD hh:mm:ss.<\/p>\n\n\n\n<p>All dates are treated as dates in business unit&#8217;s timezone.<\/p>\n","protected":false},"author":5,"featured_media":0,"parent":3928,"menu_order":199,"template":"","format":"standard","emp-category":[],"class_list":["post-3934","es","type-es","status-publish","format-standard","hentry"],"acf":[],"_links":{"self":[{"href":"https:\/\/help.expertsender.com\/pl\/wp-json\/wp\/v2\/es\/3934","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/help.expertsender.com\/pl\/wp-json\/wp\/v2\/es"}],"about":[{"href":"https:\/\/help.expertsender.com\/pl\/wp-json\/wp\/v2\/types\/es"}],"author":[{"embeddable":true,"href":"https:\/\/help.expertsender.com\/pl\/wp-json\/wp\/v2\/users\/5"}],"version-history":[{"count":2,"href":"https:\/\/help.expertsender.com\/pl\/wp-json\/wp\/v2\/es\/3934\/revisions"}],"predecessor-version":[{"id":8891,"href":"https:\/\/help.expertsender.com\/pl\/wp-json\/wp\/v2\/es\/3934\/revisions\/8891"}],"up":[{"embeddable":true,"href":"https:\/\/help.expertsender.com\/pl\/wp-json\/wp\/v2\/es\/3928"}],"wp:attachment":[{"href":"https:\/\/help.expertsender.com\/pl\/wp-json\/wp\/v2\/media?parent=3934"}],"wp:term":[{"taxonomy":"emp-category","embeddable":true,"href":"https:\/\/help.expertsender.com\/pl\/wp-json\/wp\/v2\/emp-category?post=3934"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}