{"id":1311,"date":"2011-03-08T20:26:18","date_gmt":"2011-03-08T20:26:18","guid":{"rendered":"https:\/\/www.wapshere.com\/missmiis\/?p=1311"},"modified":"2011-03-08T20:26:18","modified_gmt":"2011-03-08T20:26:18","slug":"updating-workflowdata-from-a-custom-workflow","status":"publish","type":"post","link":"https:\/\/www.wapshere.com\/missmiis\/updating-workflowdata-from-a-custom-workflow","title":{"rendered":"Updating WorkflowData from a custom workflow"},"content":{"rendered":"<p><a href=\"https:\/\/www.wapshere.com\/missmiis\/wp-content\/uploads\/2011\/03\/wf-return-values.jpg\"><\/a>Continuing in my recent theme of communicating information back from a custom workflow (see also <a href=\"https:\/\/www.wapshere.com\/missmiis\/updating-requeststatusdetail\">Updating RequestStatusDetail<\/a> and <a href=\"https:\/\/www.wapshere.com\/missmiis\/passing-data-from-a-custom-workflow-via-the-request-object\">Passing Data via the Request Object<\/a>), this post shows how you can write information into WorkflowData parameters to then use later in the workflow, perhaps\u00c2\u00a0putting it somewhere with the Function Evaluator, or using it in an Email Template.<\/p>\n<p><!--more--><\/p>\n<h3>The Basic Code<\/h3>\n<p>The code, which you will put into your custom workflow,\u00c2\u00a0is very simple. To start with, get the containing workflow which gives you access to\u00c2\u00a0any existing\u00c2\u00a0WorkflowData parameters:<\/p>\n<pre>'' Get containing Workflow\r\nDim containingWorkflow As SequentialWorkflow = Nothing\r\nIf Not SequentialWorkflow.TryGetContainingWorkflow(Me, containingWorkflow) Then\r\n    Throw New InvalidOperationException(\"Unable to get Containing Workflow\")\r\nEnd If<\/pre>\n<p>Then add a new parameter with the data you want to communicate back out of your code:<\/p>\n<pre>    containingWorkflow.WorkflowDictionary.Add(\"MyParam\", \"My Value\")<\/pre>\n<p>You can then\u00c2\u00a0use [\/\/WorkflowData\/MyParam]\u00c2\u00a0 in subsequent steps within the same FIM workflow.<\/p>\n<h3>Pass the Parameter to the Custom Workflow<\/h3>\n<p>You can make your workflow a bit more flexible if you allow the user to set the parameter name when configuring the activity.<\/p>\n<p><a href=\"https:\/\/www.wapshere.com\/missmiis\/wp-content\/uploads\/2011\/03\/wf-return-values.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1314\" title=\"wf return values\" src=\"https:\/\/www.wapshere.com\/missmiis\/wp-content\/uploads\/2011\/03\/wf-return-values.jpg\" alt=\"\" width=\"397\" height=\"30\" srcset=\"https:\/\/www.wapshere.com\/missmiis\/wp-content\/uploads\/2011\/03\/wf-return-values.jpg 397w, https:\/\/www.wapshere.com\/missmiis\/wp-content\/uploads\/2011\/03\/wf-return-values-300x22.jpg 300w\" sizes=\"auto, (max-width: 397px) 100vw, 397px\" \/><\/a><\/p>\n<p><a href=\"https:\/\/www.wapshere.com\/missmiis\/wp-content\/uploads\/2011\/03\/wf-return-values.jpg\"><\/a><\/p>\n<p>Here I&#8217;ve added a string parameter to my workflow UI. This allows the user to enter a WorkflowData parameter while configuring the activity. The following code snippet will return a message in the parameter.<\/p>\n<p><code>'' Write the return details if it was requested<br \/>\nIf Me.ResultDetails.Contains(\"WorkflowData\") Then<br \/>\n\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 Dim seperator() As Char = {\"[\", \"]\", \"\\\", \"\/\"}<br \/>\n\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 Dim wfkey As String = Me.ResultDetails.Split(seperator, StringSplitOptions.RemoveEmptyEntries)(1)<br \/>\n\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 containingWorkflow.WorkflowDictionary.Add(wfkey, returnMessage)<br \/>\nEnd If<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Continuing in my recent theme of communicating information back from a custom workflow (see also Updating RequestStatusDetail and Passing Data via the Request Object), this post shows how you can write information into WorkflowData parameters to then use later in the workflow, perhaps\u00c2\u00a0putting it somewhere with the Function Evaluator, or using it in an Email&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"footnotes":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":[]},"categories":[42,30,45],"tags":[],"class_list":["post-1311","post","type-post","status-publish","format-standard","hentry","category-fim-2010","category-vbnet","category-workflow"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/pkp1o-l9","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/posts\/1311","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/comments?post=1311"}],"version-history":[{"count":6,"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/posts\/1311\/revisions"}],"predecessor-version":[{"id":1319,"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/posts\/1311\/revisions\/1319"}],"wp:attachment":[{"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/media?parent=1311"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/categories?post=1311"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/tags?post=1311"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}