{"id":236,"date":"2016-10-20T07:28:00","date_gmt":"2016-10-20T07:28:00","guid":{"rendered":""},"modified":"2020-01-09T13:34:16","modified_gmt":"2020-01-09T13:34:16","slug":"dynamic-participant-step","status":"publish","type":"post","link":"https:\/\/lhotsetechnologies.com\/blog\/dynamic-participant-step\/","title":{"rendered":"Dynamic Participant Step"},"content":{"rendered":"<div dir=\"ltr\" style=\"text-align: left;\">In this blog, I will discuss about Dynamic Participant Step:<br \/><span style=\"color: purple;\"><br \/><\/span><span style=\"color: purple;\">1. What is the use of Dynamic Participant Step?<\/span><br \/><span style=\"color: purple;\">2. How can we write Custom Dynamic Participant Step?<\/span><br \/><span style=\"color: purple;\">3.How can we use Dynamic Participant Step?<\/span><br \/><span style=\"color: purple;\"><br \/><\/span><b>Use of&nbsp;<\/b><b>Dynamic<\/b><span style=\"color: purple;\">&nbsp;<\/span><b>participant step:<\/b><br \/><b><br \/><\/b>Workflow Dynamic Participant Step is used when the user or a group to perform an activity in that step is selected automatically at run time based on some business logic unlike the user or a group are pre-selected. When we select the dynamic participant step in the workflow, we need to select the respective participant user from the drop down. There are many script\/service available out of the box to select from or we can write our own participant chooser service as well which will be discussed further in this post.<br \/><i><span style=\"color: purple;\"><br \/><\/span><\/i><b>Custom Dynamic Participant Step:<\/b><br \/><b><br \/><\/b>For crating the Custom Dynamic Participant Step we have to implement <b>ParticipantStepChooser<\/b>&nbsp;in our java class which provide us <b>getParticipant <\/b>method with three parameter <b>Workitem<\/b>, <b>WorkflowSession <\/b>and <b>MetaDataMap<\/b>.<\/p>\n<p>Register this java class as a component and add some properties as <b>enabled<\/b>, <b>immediate<\/b>, these property indicates-<br \/><i><span style=\"color: purple;\">That this service will be enabled immediate at the time of deployment of your project.<\/span><\/i><\/p>\n<p>Now register your class as a service with some configurations-<br \/>i.e. add a property named as &#8220;<b>chooser.label&#8221;. <\/b>This property defines a name of your process i.e. in workflow participant chooser step, you are able to see this process in your participant chooser drag drop menu with a name define using this property.<\/p>\n<p>Our final code will look like this:<\/p>\n<p><i><span style=\"color: purple;\">package com.havells.services;<\/span><\/i><br \/><i><span style=\"color: purple;\"><br \/><\/span><\/i><i><span style=\"color: purple;\">import com.adobe.granite.workflow.WorkflowException;<\/span><\/i><br \/><i><span style=\"color: purple;\">import com.adobe.granite.workflow.WorkflowSession;<\/span><\/i><br \/><i><span style=\"color: purple;\">import com.adobe.granite.workflow.exec.HistoryItem;<\/span><\/i><br \/><i><span style=\"color: purple;\">import com.adobe.granite.workflow.exec.ParticipantStepChooser;<\/span><\/i><br \/><i><span style=\"color: purple;\">import com.adobe.granite.workflow.exec.WorkItem;<\/span><\/i><br \/><i><span style=\"color: purple;\">import com.adobe.granite.workflow.exec.Workflow;<\/span><\/i><br \/><i><span style=\"color: purple;\">import com.adobe.granite.workflow.metadata.MetaDataMap;<\/span><\/i><br \/><i><span style=\"color: purple;\"><br \/><\/span><\/i><i><span style=\"color: purple;\">import java.util.List;<\/span><\/i><br \/><i><span style=\"color: purple;\"><br \/><\/span><\/i><i><span style=\"color: purple;\">import org.apache.felix.scr.annotations.Component;<\/span><\/i><br \/><i><span style=\"color: purple;\">import org.apache.felix.scr.annotations.Properties;<\/span><\/i><br \/><i><span style=\"color: purple;\">import org.apache.felix.scr.annotations.Service;<\/span><\/i><br \/><i><span style=\"color: purple;\">import org.slf4j.Logger;<\/span><\/i><br \/><i><span style=\"color: purple;\">import org.slf4j.LoggerFactory;<\/span><\/i><\/p>\n<p><i><span style=\"color: purple;\">@Component(immediate=true)<\/span><\/i><br \/><i><span style=\"color: purple;\">@Service<\/span><\/i><br \/><i><span style=\"color: purple;\">@Properties({@org.apache.felix.scr.annotations.Property(name=&#8221;service.description&#8221;, value={&#8220;Sample Implementation of dynamic participant chooser.&#8221;}),<\/span><\/i><br \/><i><span style=\"color: purple;\"><span style=\"white-space: pre;\">   <\/span>@org.apache.felix.scr.annotations.Property(name=&#8221;chooser.label&#8221;, value={&#8220;Workflow Participant Chooser&#8221;})<\/span><\/i><br \/><i><span style=\"color: purple;\"><span style=\"white-space: pre;\">   <\/span>})<\/span><\/i><br \/><i><span style=\"color: purple;\">public class CustomStepForDynamicParticipant<\/span><\/i><br \/><i><span style=\"color: purple;\">&nbsp; implements ParticipantStepChooser<\/span><\/i><br \/><i><span style=\"color: purple;\">{<\/span><\/i><br \/><i><span style=\"color: purple;\">&nbsp; private static final Logger logger = LoggerFactory.getLogger(CustomStepForDynamicParticipant.class);<\/span><\/i><br \/><i><span style=\"color: purple;\">&nbsp; &nbsp;<\/span><\/i><br \/><i><span style=\"color: purple;\">&nbsp; public String getParticipant(WorkItem workitem, WorkflowSession wfSession, MetaDataMap metaDataMap)<\/span><\/i><br \/><i><span style=\"color: purple;\">&nbsp; &nbsp; throws WorkflowException<\/span><\/i><br \/><i><span style=\"color: purple;\">&nbsp; {<\/span><\/i><br \/><i><span style=\"color: purple;\">&nbsp; &nbsp; logger.info(&#8220;################ Inside the SampleProcessStepChooserImpl GetParticipant ##########################&#8221;);<\/span><\/i><br \/><i><span style=\"color: purple;\">&nbsp; &nbsp; String participant = &#8220;admin&#8221;;<\/span><\/i><br \/><i><span style=\"color: purple;\">&nbsp; &nbsp; Workflow workflow = workitem.getWorkflow();<\/span><\/i><br \/><i><span style=\"color: purple;\">&nbsp; &nbsp; String initiator = workflow.getInitiator();<\/span><\/i><br \/><i><span style=\"color: purple;\">&nbsp; &nbsp; List&lt;HistoryItem&gt; wfHistory = wfSession.getHistory(workflow);<\/span><\/i><br \/><i><span style=\"color: purple;\">&nbsp; &nbsp; if (!wfHistory.isEmpty()) {<\/span><\/i><br \/><i><span style=\"color: purple;\">&nbsp; &nbsp; &nbsp; participant = initiator;<\/span><\/i><br \/><i><span style=\"color: purple;\">&nbsp; &nbsp; } else {<\/span><\/i><br \/><i><span style=\"color: purple;\">&nbsp; &nbsp; &nbsp; participant = &#8220;admin&#8221;;<\/span><\/i><br \/><i><span style=\"color: purple;\">&nbsp; &nbsp; }<\/span><\/i><br \/><i><span style=\"color: purple;\">&nbsp; &nbsp; logger.info(&#8220;####### Participant : &#8221; + participant + &#8221; ##############&#8221;);<\/span><\/i><br \/><i><span style=\"color: purple;\">&nbsp; &nbsp; return participant;<\/span><\/i><br \/><i><span style=\"color: purple;\">&nbsp; }<\/span><\/i><br \/><i><span style=\"color: purple;\">}<\/span><\/i><\/p>\n<p>To know How can we use this step <a href=\"http:\/\/lhotsetechnologies.com\/blog\/send-an-email-for-approval-to-the-admin-in-a-cq5-aem-page-publishing-workflow\/\" target=\"_blank\" rel=\"noopener noreferrer\"><i><span style=\"color: purple;\">click here<\/span><\/i>:<\/a><\/p>\n<p><i><b><span style=\"color: purple;\">Be Happy<\/span><\/b><\/i>&nbsp;<\/div>\n","protected":false},"excerpt":{"rendered":"<p>In this blog, I will discuss about Dynamic Participant Step:1. What is the use of Dynamic Participant Step?2. How can [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,195,82,196,194,197,124],"tags":[],"class_list":["post-236","post","type-post","status-publish","format-standard","hentry","category-aem","category-chooser-label-property","category-cq5","category-custom-dynamic-participant-step","category-dynamic-participant-step","category-participantstepchooser","category-workflow"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.9 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Dynamic Participant Step - AEM Blog | Lhotse Technologies<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/lhotsetechnologies.com\/blog\/dynamic-participant-step\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Dynamic Participant Step - AEM Blog | Lhotse Technologies\" \/>\n<meta property=\"og:description\" content=\"In this blog, I will discuss about Dynamic Participant Step:1. What is the use of Dynamic Participant Step?2. How can [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/lhotsetechnologies.com\/blog\/dynamic-participant-step\/\" \/>\n<meta property=\"og:site_name\" content=\"AEM Blog | Lhotse Technologies\" \/>\n<meta property=\"article:published_time\" content=\"2016-10-20T07:28:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-01-09T13:34:16+00:00\" \/>\n<meta name=\"author\" content=\"Team Lhotse\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Team Lhotse\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/lhotsetechnologies.com\/blog\/dynamic-participant-step\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/lhotsetechnologies.com\/blog\/dynamic-participant-step\/\"},\"author\":{\"name\":\"Team Lhotse\",\"@id\":\"https:\/\/lhotsetechnologies.com\/blog\/#\/schema\/person\/fd7bee89b050d7c7195fc75b681b053d\"},\"headline\":\"Dynamic Participant Step\",\"datePublished\":\"2016-10-20T07:28:00+00:00\",\"dateModified\":\"2020-01-09T13:34:16+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/lhotsetechnologies.com\/blog\/dynamic-participant-step\/\"},\"wordCount\":493,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/lhotsetechnologies.com\/blog\/#organization\"},\"articleSection\":[\"AEM\",\"Chooser.label property\",\"CQ5\",\"Custom Dynamic participant step\",\"Dynamic Participant Step\",\"ParticipantStepChooser\",\"workflow\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/lhotsetechnologies.com\/blog\/dynamic-participant-step\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/lhotsetechnologies.com\/blog\/dynamic-participant-step\/\",\"url\":\"https:\/\/lhotsetechnologies.com\/blog\/dynamic-participant-step\/\",\"name\":\"Dynamic Participant Step - AEM Blog | Lhotse Technologies\",\"isPartOf\":{\"@id\":\"https:\/\/lhotsetechnologies.com\/blog\/#website\"},\"datePublished\":\"2016-10-20T07:28:00+00:00\",\"dateModified\":\"2020-01-09T13:34:16+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/lhotsetechnologies.com\/blog\/dynamic-participant-step\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/lhotsetechnologies.com\/blog\/dynamic-participant-step\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/lhotsetechnologies.com\/blog\/dynamic-participant-step\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/lhotsetechnologies.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Dynamic Participant Step\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/lhotsetechnologies.com\/blog\/#website\",\"url\":\"https:\/\/lhotsetechnologies.com\/blog\/\",\"name\":\"AEM Blog | Lhotse Technologies\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/lhotsetechnologies.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/lhotsetechnologies.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/lhotsetechnologies.com\/blog\/#organization\",\"name\":\"AEM Blog | Lhotse Technologies\",\"url\":\"https:\/\/lhotsetechnologies.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/lhotsetechnologies.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/lhotsetechnologies.com\/blog\/wp-content\/uploads\/2019\/07\/lhotse-logo.png\",\"contentUrl\":\"https:\/\/lhotsetechnologies.com\/blog\/wp-content\/uploads\/2019\/07\/lhotse-logo.png\",\"width\":539,\"height\":172,\"caption\":\"AEM Blog | Lhotse Technologies\"},\"image\":{\"@id\":\"https:\/\/lhotsetechnologies.com\/blog\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/lhotsetechnologies.com\/blog\/#\/schema\/person\/fd7bee89b050d7c7195fc75b681b053d\",\"name\":\"Team Lhotse\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/lhotsetechnologies.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/?s=96&d=mm&r=g\",\"caption\":\"Team Lhotse\"},\"url\":\"https:\/\/lhotsetechnologies.com\/blog\/author\/team-lhotse\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Dynamic Participant Step - AEM Blog | Lhotse Technologies","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:\/\/lhotsetechnologies.com\/blog\/dynamic-participant-step\/","og_locale":"en_US","og_type":"article","og_title":"Dynamic Participant Step - AEM Blog | Lhotse Technologies","og_description":"In this blog, I will discuss about Dynamic Participant Step:1. What is the use of Dynamic Participant Step?2. How can [&hellip;]","og_url":"https:\/\/lhotsetechnologies.com\/blog\/dynamic-participant-step\/","og_site_name":"AEM Blog | Lhotse Technologies","article_published_time":"2016-10-20T07:28:00+00:00","article_modified_time":"2020-01-09T13:34:16+00:00","author":"Team Lhotse","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Team Lhotse","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/lhotsetechnologies.com\/blog\/dynamic-participant-step\/#article","isPartOf":{"@id":"https:\/\/lhotsetechnologies.com\/blog\/dynamic-participant-step\/"},"author":{"name":"Team Lhotse","@id":"https:\/\/lhotsetechnologies.com\/blog\/#\/schema\/person\/fd7bee89b050d7c7195fc75b681b053d"},"headline":"Dynamic Participant Step","datePublished":"2016-10-20T07:28:00+00:00","dateModified":"2020-01-09T13:34:16+00:00","mainEntityOfPage":{"@id":"https:\/\/lhotsetechnologies.com\/blog\/dynamic-participant-step\/"},"wordCount":493,"commentCount":0,"publisher":{"@id":"https:\/\/lhotsetechnologies.com\/blog\/#organization"},"articleSection":["AEM","Chooser.label property","CQ5","Custom Dynamic participant step","Dynamic Participant Step","ParticipantStepChooser","workflow"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/lhotsetechnologies.com\/blog\/dynamic-participant-step\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/lhotsetechnologies.com\/blog\/dynamic-participant-step\/","url":"https:\/\/lhotsetechnologies.com\/blog\/dynamic-participant-step\/","name":"Dynamic Participant Step - AEM Blog | Lhotse Technologies","isPartOf":{"@id":"https:\/\/lhotsetechnologies.com\/blog\/#website"},"datePublished":"2016-10-20T07:28:00+00:00","dateModified":"2020-01-09T13:34:16+00:00","breadcrumb":{"@id":"https:\/\/lhotsetechnologies.com\/blog\/dynamic-participant-step\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/lhotsetechnologies.com\/blog\/dynamic-participant-step\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/lhotsetechnologies.com\/blog\/dynamic-participant-step\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/lhotsetechnologies.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Dynamic Participant Step"}]},{"@type":"WebSite","@id":"https:\/\/lhotsetechnologies.com\/blog\/#website","url":"https:\/\/lhotsetechnologies.com\/blog\/","name":"AEM Blog | Lhotse Technologies","description":"","publisher":{"@id":"https:\/\/lhotsetechnologies.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/lhotsetechnologies.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/lhotsetechnologies.com\/blog\/#organization","name":"AEM Blog | Lhotse Technologies","url":"https:\/\/lhotsetechnologies.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/lhotsetechnologies.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/lhotsetechnologies.com\/blog\/wp-content\/uploads\/2019\/07\/lhotse-logo.png","contentUrl":"https:\/\/lhotsetechnologies.com\/blog\/wp-content\/uploads\/2019\/07\/lhotse-logo.png","width":539,"height":172,"caption":"AEM Blog | Lhotse Technologies"},"image":{"@id":"https:\/\/lhotsetechnologies.com\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/lhotsetechnologies.com\/blog\/#\/schema\/person\/fd7bee89b050d7c7195fc75b681b053d","name":"Team Lhotse","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/lhotsetechnologies.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/?s=96&d=mm&r=g","caption":"Team Lhotse"},"url":"https:\/\/lhotsetechnologies.com\/blog\/author\/team-lhotse\/"}]}},"_links":{"self":[{"href":"https:\/\/lhotsetechnologies.com\/blog\/wp-json\/wp\/v2\/posts\/236","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lhotsetechnologies.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lhotsetechnologies.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lhotsetechnologies.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/lhotsetechnologies.com\/blog\/wp-json\/wp\/v2\/comments?post=236"}],"version-history":[{"count":1,"href":"https:\/\/lhotsetechnologies.com\/blog\/wp-json\/wp\/v2\/posts\/236\/revisions"}],"predecessor-version":[{"id":292,"href":"https:\/\/lhotsetechnologies.com\/blog\/wp-json\/wp\/v2\/posts\/236\/revisions\/292"}],"wp:attachment":[{"href":"https:\/\/lhotsetechnologies.com\/blog\/wp-json\/wp\/v2\/media?parent=236"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lhotsetechnologies.com\/blog\/wp-json\/wp\/v2\/categories?post=236"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lhotsetechnologies.com\/blog\/wp-json\/wp\/v2\/tags?post=236"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}