Assign task to user who executed or submitted an AF | Community
Skip to main content
Level 2
Mar 17, 2022 10:50 PM UTC
Solved

Assign task to user who executed or submitted an AF

Hello everyone,

 

I was wondering if it is possible to assign a task to the user you executed a workflow or submitted an adaptive form. I'm trying to recreate that scenario, but from the options of the assign task it doesn't look possible. Does anybody know how can I implement this>

 

 

Best regards,

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Anmol_Bhardwaj
Anmol_BhardwajAccepted solution
New Participant
Mar 21, 2022 9:13 AM UTC

Yes. 

You can do it in 2 ways:

 

1. Create a ECMA script and assign the task required to the user who started the last step/workflow. The workflow initiator id would be present in the workflow metadata by the property name "initiatorId". Now, you can add this ECMA script in the process step of your workflow.

2. You can achieve the same through Java and the property would be the same, just the fetching of workflow metadata would be different.

 

Help Docs: https://experienceleague.adobe.com/docs/experience-manager-65/developing/extending-aem/extending-workflows/workflows-customizing-extending.html?lang=en 

4 replies

crich2784
Level 6
Mar 22, 2022 8:10 PM UTC

This is how I did it in a custom java component:

 

String wfinitiatorId = workItem.getWorkflow().getInitiator();
log.info(" Initiator id is: " + wfinitiatorId);

Translate
SebasRiosAuthor
Level 2
Mar 22, 2022 8:14 PM UTC

Thanks! I was able to assign it to the initiator using this code for my java component!

 

Translate
Anmol_Bhardwaj
Anmol_BhardwajAccepted solution
New Participant
Mar 21, 2022 9:13 AM UTC

Yes. 

You can do it in 2 ways:

 

1. Create a ECMA script and assign the task required to the user who started the last step/workflow. The workflow initiator id would be present in the workflow metadata by the property name "initiatorId". Now, you can add this ECMA script in the process step of your workflow.

2. You can achieve the same through Java and the property would be the same, just the fetching of workflow metadata would be different.

 

Help Docs: https://experienceleague.adobe.com/docs/experience-manager-65/developing/extending-aem/extending-workflows/workflows-customizing-extending.html?lang=en 

Translate
crich2784
Level 6
Mar 22, 2022 4:03 PM UTC

@anmol_bhardwaj 

MetaDataMap vars = wfd.getMetaDataMap();
String initiatorId = vars.get("initiatorId", "undefined").trim();
log.info(" InitiatorId is: " + initiatorId);

 

 

We created a custom workflow step in Java.  This is the second step in our workflow.  The initiatorId is undefined.  When is initiatorId set?

Translate