Level 1
Level 2
Melden Sie sich an, um alle Badges zu sehen
Hi,
I have a workflow that includes a dialog participant step, and I am invoking a servlet to retrieve dropdown values. I have two different workflows calling the same servlet, and now I want to know the workflow name within the servlet. I tried the code below, but the workItem is always null.
Any help is appreciated. Thank you.
WorkflowSession workflowSession = request.getResourceResolver().adaptTo(WorkflowSession.class);
if (workflowSession != null) {
WorkItem workItem = (WorkItem) request.getAttribute("com.adobe.granite.workflow.exec.WorkItem");
if (workItem != null) {
Workflow workflow = workItem.getWorkflow();
WorkflowModel workflowModel = workflow.getWorkflowModel();
String workflowModelId = workflowModel.getId();
String workflowModelTitle = workflowModel.getTitle();
log.info("Workflow Model ID: {}", workflowModelId);
log.info("Workflow Model Title: {}", workflowModelTitle);
}
}
@EstebanBustamante @arunpatidar
Gelöst! Gehe zu Lösung.
Zugriffe
Antworten
Likes gesamt
Hi @Divya_T13
You won't be able to get the workflow context in the servlet but you can check the request path in the servlet where you may utilize the workflow name/path to identofy which workflow model is invoking the servlet.
Zugriffe
Antworten
Likes gesamt
Hi @Divya_T13
Most probably its happening because workitem is not available in the servlet context .Few suggestions any possibility of passing this information as a request parameter to the servlet to identify the workflow,
Servlet is invoked from UI or from inside any workflow itself , if from workflow try passing the workflow name in workflow metadata map and retrieve the same in the servlet.
Zugriffe
Antworten
Likes gesamt
We are invoking servlet from a component dialog datasource node. And this component is included in Dialog path of Dynamic Participant step which will load when user takes action to complete that step. We will be able to get metadata map in any workflow implementation classes but not sure how to retrieve that in servlet.
Zugriffe
Antworten
Likes gesamt
How are you calling the servlet? What parameters do you pass to the servlet? You will get workflow session in the execute method in a workflow process but you might not get it in a servlet.
Why not pass the wf model as a param to the servlet?
Zugriffe
Antworten
Likes gesamt
We are invoking servlet from a component dialog datasource node and not passing any parameters. wf model is dynamic as we have same servlet invoked by different workflows.
Zugriffe
Antworten
Likes gesamt
Add requestpathinfo as a property in datasource node and make use of that to distinguish the workflow model. You can follow something like this - https://kiransg.com/tag/datasource-servlet/
Zugriffe
Antworten
Likes gesamt
Hi @SreenivasBr
Thank you for your inputs and help.
We'll be able to identify the wfname through request.getQueryString() in our servlet.
Zugriffe
Antworten
Likes gesamt
Hi @Divya_T13
You won't be able to get the workflow context in the servlet but you can check the request path in the servlet where you may utilize the workflow name/path to identofy which workflow model is invoking the servlet.
Zugriffe
Antworten
Likes gesamt
Hi @arunpatidar
Thank you so much for your inputs.
originalURI, embedded within a series of request wrappers, contains the complete URL along with query parameters: /{contextpath}/libs/cq/inbox/content/inbox/dialogs/dialogInjectionRender.html?item=%2Fvar%2Fworkflow%2Finstances%2Fserver0%2F2025-01-06%2Ftest-custom-approval-workflow_27%2FworkItems%2Fnode2_var_workflow_instances_server0_2025-01-06_test-custom-approval-workflow_27&ch_ck=1736406875098.
In the servlet, we can identify the workflow name (wfname) through request.getQueryString()
Zugriffe
Antworten
Likes gesamt
Hi @arunpatidar
Thank you for your inputs.
originalURI embedded within a series of request wrappers has complete url along with query parameters
/{contextpath}/libs/cq/inbox/content/inbox/dialogs/dialogInjectionRender.html?item=%2Fvar%2Fworkflow%2Finstances%2Fserver0%2F2025-01-06%2Ftest-custom-approval-workflow_27%2FworkItems%2Fnode2_var_workflow_instances_server0_2025-01-06_test-custom-approval-workflow_27&ch_ck=1736406875098.
In servlet, we will be able to identify the wfname through request.getQueryString()
Zugriffe
Antworten
Likes gesamt
Hi @arunpatidar
Thank you for your inputs and help.
In servlet, we will be able to identify the wfname through request.getQueryString()
originalURI embedded within a series of request wrappers has complete url along with query parameters
Zugriffe
Antworten
Likes gesamt
Zugriffe
Likes
Antworten
Zugriffe
Likes
Antworten