Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.
SOLVED

Assign task to user who executed or submitted an AF

Avatar

Level 2

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>

 

SebasRios34_0-1647557409040.png

 

Best regards,

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

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-wor... 

View solution in original post

4 Replies

Avatar

Correct answer by
Community Advisor

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-wor... 

Avatar

Level 7

@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?

Avatar

Level 7

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

 

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

Avatar

Level 2

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