AEM Workflow - Unable to Save an Array to WorkItem metadatamap | Community
Skip to main content
New Participant
May 28, 2020
Solved

AEM Workflow - Unable to Save an Array to WorkItem metadatamap

  • May 28, 2020
  • 2 replies
  • 7276 views

Hi,

I am writing a custom workflow process step where I need to save an array of values into workitem metadata map, that will be used later by subsequent steps by reading through history.

Interestingly when I add an array or List object to WorkItem Metadata map, it is not persisted in workitem/metadata node whereas normal string/boolean variables are persisted in WorkItem metadata node.

 

I am able to save array or list object as property to Workflow and WorkflowData MetadataMap but it's just not working with workItem metadata map

workItem.getMetaDataMap().put("key", Value);

where Value is an array of String

I will appreciate any help on this.

 

Thanks,

Pankaj

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 Vijayalakshmi_S

Hi @pankaj49319,

 

As mentioned in MetaDataMaps section in the link shared by @hamid1350, using WorkflowData's MetaDataMap is recommended to share data across steps. 

WorkItem's MetaDataMap is specific to that step (while it is running).

 

Is there any particular reason/need that you are looking to read it from history for access in subsequent steps (as you have mentioned in your original post)

2 replies

Vijayalakshmi_S
Vijayalakshmi_SAccepted solution
New Participant
May 29, 2020

Hi @pankaj49319,

 

As mentioned in MetaDataMaps section in the link shared by @hamid1350, using WorkflowData's MetaDataMap is recommended to share data across steps. 

WorkItem's MetaDataMap is specific to that step (while it is running).

 

Is there any particular reason/need that you are looking to read it from history for access in subsequent steps (as you have mentioned in your original post)

New Participant
May 29, 2020

Hi,

We have a custom workflow for content activation governance where we are already following the best practices.

This workflow has a dialog step where user provides certain information that decides how course of approval and activation flow will take place. So the data user provides in dialog is stored in dialog step workitem's metadata map and once the step completes it is archived and becomes part of history items. this is standard workflow process, we can only store dialog inputs either with payload or work item.

In subsequent steps where we want to read the values user provided, history items are iterated for specific properties of workitem metadata map.

Everything was working fine and then we got an enhancement where we had to mimic user input pro-grammatically as if user has provided it and all the subsequent steps would read it in same way as user data is consumed, as I explained earlier.

I added a process step that fetches data to be written and adds it to workitem metadata map and when workitem is archived upon completion metadata is persisted under history and history can be iterated by subsequent steps for value of specific properties. I was able to save String and Boolean values in this manner but when I added array or list of String to metadata map of workitem. It is not persisted to metadata map in history, String & boolean values are still written back.

 

Hope the explanation helps, 

 

Employee
May 29, 2020
New Participant
May 29, 2020

Thanks Hamid,

We are following most of things outlined in this article, My situation is a specific case where we have simulate user inputs to dialog step that are generally stored with workitem metadata map.
Please see my response to other post for implementation.

This scenario in not covered in documentation