Expand my Community achievements bar.

Learn about Edge Delivery Services in upcoming GEM session
SOLVED

Form-centric workflow: How to implement a OSGi service for custom metadata (assign task)

Avatar

Level 2

Hello

Currently I'm working on forms-centric workflows. I'm using the assign task component and I need to add some custom values into the custom email templates. As per documentation (https://docs.adobe.com/content/help/en/experience-manager-65/forms/publish-process-aem-forms/use-met... I should be able to write my own OSGi service which prepares the metadata map.

Unfortunately I'm not able to successfully get the OSGi service listed in the field Assign Task --> Advanced --> Custom Metadata. It seems that the above linked documentation is incomplete (e.g. see point 4).

Was anyone able to create such a OSGi service and get it listed for selection? If so, is there a working example available?

Kind regards
Richard

1 Accepted Solution

Avatar

Correct answer by
Level 9
13 Replies

Avatar

Level 9

I will send you a sample code soon

i have it somewhere on my laptop

Avatar

Correct answer by
Level 9

Avatar

Level 2
Thank you very much! Can you also provide the necessary maven dependency?

Avatar

Level 2

Thank you very much!

 

Can you also provide the necessary maven dependency? When I implement the mentioned interface I have to override

public Map<String, String> getUserMetadata(WorkItem workItem, WorkflowSession workflowSession, MetaDataMap metadataMap) {
}

 

I'm working with AEM Forms 6.5 SP6.

Avatar

Level 9
<dependency> <groupId>com.adobe.aemfd</groupId> <artifactId>aemfd-client-sdk</artifactId> <version>6.0.122</version> </dependency>

Avatar

Level 2
Thank you for the dependency! The versioning of the dependencies is a little confusing. Anyhow, I was now able to implement the interface but the implementation is still not shown in the selection. I'm currently investigating why (any hints are welcome )

Avatar

Level 2

I got it working but I had to adapt the code a bit:

 

import com.adobe.fd.workspace.service.external.WorkitemUserMetadataService;
import com.adobe.granite.workflow.WorkflowSession;
import com.adobe.granite.workflow.exec.WorkItem;
import com.adobe.granite.workflow.metadata.MetaDataMap;

import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Properties;
import org.apache.felix.scr.annotations.Property;
import org.apache.felix.scr.annotations.Service;
import org.osgi.framework.Constants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.HashMap;
import java.util.Map;

@Component
@Service
@Properties({
        @property(name = Constants.SERVICE_DESCRIPTION, value = "A sample implementation of a user metadata service."),
        @property(name = WorkitemUserMetadataService.SERVICE_PROPERTY_LABEL, value = "Default User Metadata Service")})
public class WorkItemUserServiceImpl implements WorkitemUserMetadataService {
    private static final Logger log = LoggerFactory.getLogger(WorkItemUserServiceImpl.class);

    @Override
    public Map<String, String> getUserMetadata(WorkItem workItem, WorkflowSession workflowSession, MetaDataMap metadataMap) {
        HashMap<String, String> customMetadataMap = new HashMap<String, String>();
        return customMetadataMap;
    }
}

Avatar

Level 9

Let me know If you have questions on the link I sent you

we will update the other link as well

thanks

Avatar

Level 2
When implementing the mentioned interface, I get asked to implement getUserMetadataMap(). Can you therefore also add the information regarding the needed maven dependency where the package with the interface is included? I assume, I'm working with an outdated version.

Avatar

Level 2
I saw, that the interface is included in the aemfd-client-sdk dependency. But the newest available version is from 6.3.0 (https://mvnrepository.com/artifact/com.adobe.aemfd/aemfd-client-sdk?repo=adobe-public). Maybe you have a newer version for 6.5 to publish?

Avatar

Level 9

Yes the versions are confusing. We are going to start naming the versions which are in sync with AEM forms release version

sorry for the confusion