Assign task to user who executed or submitted an AF | Community
Skip to main content
Level 2
March 17, 2022
Solved

Assign task to user who executed or submitted an AF

  • March 17, 2022
  • 2 replies
  • 1108 views

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.
Best answer by Anmol_Bhardwaj

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 

2 replies

Anmol_Bhardwaj
Community Advisor
Anmol_BhardwajCommunity AdvisorAccepted solution
Community Advisor
March 21, 2022

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 

crich2784
Level 6
March 22, 2022

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

crich2784
Level 6
March 22, 2022

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

 

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

SebasRiosAuthor
Level 2
March 22, 2022

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