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

Avatar

Avatar

Richard_Wegier

Avatar

Richard_Wegier

Richard_Wegier

04-11-2020

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

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar

GirishBedekar

Avatar

GirishBedekar

GirishBedekar

04-11-2020

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

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.

<dependency> <groupId>com.adobe.aemfd</groupId> <artifactId>aemfd-client-sdk</artifactId> <version>6.0.122</version> </dependency>
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 🙂 )
Yes the version are confusing

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;
    }
}

Answers (3)

Answers (3)

Avatar

Avatar

GirishBedekar

Avatar

GirishBedekar

GirishBedekar

04-11-2020

I will send you a sample code soon

i have it somewhere on my laptop

Avatar

Avatar

GirishBedekar

Avatar

GirishBedekar

GirishBedekar

04-11-2020

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 

Avatar

Avatar

GirishBedekar

Avatar

GirishBedekar

GirishBedekar

04-11-2020

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

we will update the other link as well

thanks