Cannot write properties to workflow instance at workflow dialog participant step | Community
Skip to main content
Level 3
January 19, 2023
Solved

Cannot write properties to workflow instance at workflow dialog participant step

  • January 19, 2023
  • 1 reply
  • 1077 views

Dear community,

I need a workflow that allows users to upload a file to DAM at one step, the same file can be downloaded at another step ahead.

Here comes the issue, I need WorkflowSession and WorkItem to write properties on workflow instance, but I cannot get them on the Servlet that adds asset to DAM.

 

find snippet below, the workitemId is null;

ResourceResolver resolver = request.getResourceResolver();
String workitemId = request.getParameter("item");

However, this part does work if I call the servlet with "sling:resourceType". So it's about the object that calls servlet I assume.

 

So there are 2 ways to get WorkflowSession and WorkItem

1. Using "custom process step", WorkflowProcess interface get me these two.

2. Calling servlet with sling:resourceType.

But in my case, I can only imagine designing upload / download step with participant dialog step. As I click custom upload button, the servlet writes the file path on workflow instance, and another servlet ahead fetch the property with same approach.

 

Is there anything I can do to get WorkflowSession and WorkItem with dialog participant step?

Or I could use other steps in my workflow to achieve this?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Siva_Sogalapalli

Thanks @yusheng for sharing additional details.

I'm not sure why you're using servlet to upload the file in this case. 

May be you can also try below steps:
1. Dialog participant where the workflow user browse the file.

    - In this step, it will just store the image/file details in workflow payload.

2. Custom workflow process step : To read the file path from the payload and then upload the file to AEM. Below you can find the sample servlet to upload the asset in AEM. So you can the same code in your workflow process which will upload file in DAM. 

https://github.com/arunpatidar02/aem63app-repo/blob/master/java/UploadAssets.java 

 

3.  Other process steps goes here to complete your business logic.

4.  You can even send email notifications to the participants with all the required information to review it.

5. Assign the step to the participant to publish/Reject etc..

 

Hope this helps.

1 reply

Siva_Sogalapalli
Community Advisor
Community Advisor
January 19, 2023

@yusheng   Are you creating workflow just to upload the file into DAM and download same on another step or it also has some other business logic to execute in the between upload & download the file from DAM? 

YuShengAuthor
Level 3
January 19, 2023

Hi @siva_sogalapalli 

There might be other business logic in between upload & download, but would be separate from upload & download steps.

 

The use case is about the workflow initiator uploads file(s) along with a page, reviewers ahead should be able to download that file and proceed to next step (say, activate the page).

Siva_Sogalapalli
Community Advisor
Siva_SogalapalliCommunity AdvisorAccepted solution
Community Advisor
January 19, 2023

Thanks @yusheng for sharing additional details.

I'm not sure why you're using servlet to upload the file in this case. 

May be you can also try below steps:
1. Dialog participant where the workflow user browse the file.

    - In this step, it will just store the image/file details in workflow payload.

2. Custom workflow process step : To read the file path from the payload and then upload the file to AEM. Below you can find the sample servlet to upload the asset in AEM. So you can the same code in your workflow process which will upload file in DAM. 

https://github.com/arunpatidar02/aem63app-repo/blob/master/java/UploadAssets.java 

 

3.  Other process steps goes here to complete your business logic.

4.  You can even send email notifications to the participants with all the required information to review it.

5. Assign the step to the participant to publish/Reject etc..

 

Hope this helps.