Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

How do I Modify the Workflow Work Item Page?

Avatar

Avatar
Springboard
Level 2
JonMaguire
Level 2

Likes

2 likes

Total Posts

24 posts

Correct Reply

0 solutions
Top badges earned
Springboard
Validate 1
Give Back
Ignite 1
Establish
View profile

Avatar
Springboard
Level 2
JonMaguire
Level 2

Likes

2 likes

Total Posts

24 posts

Correct Reply

0 solutions
Top badges earned
Springboard
Validate 1
Give Back
Ignite 1
Establish
View profile
JonMaguire
Level 2

28-05-2021

I'm wanting to modify the Initiator field value on the WORKFLOW INFO tab on the Work Item page in AEM 6.5. Currently it displays the ID of the workflow initiator. I want to change the value to the name of the initiator. I've searched documentation and have dug around in CRX, but I am a bit lost on how to accomplish this. I'm hoping someone can point me in the right direction?

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Give Back 100
Level 10
asutosh_jena
Level 10

Likes

559 likes

Total Posts

676 posts

Correct Reply

194 solutions
Top badges earned
Give Back 100
Boost 500
Affirm 100
Ignite 1
Establish
View profile

Avatar
Give Back 100
Level 10
asutosh_jena
Level 10

Likes

559 likes

Total Posts

676 posts

Correct Reply

194 solutions
Top badges earned
Give Back 100
Boost 500
Affirm 100
Ignite 1
Establish
View profile
asutosh_jena
Level 10

28-05-2021

Hi @JonMaguire 

 

createWorkflowInstance() of com.adobe.granite.workflow.core.jcr.WorkflowManager.java class is used to create the workflow instance and populate all the metadata such as (data, history, metaData and workItems node). 

 

public WorkflowImpl createWorkflowInstance(WorkflowModel model, WorkflowData workdata, MetaDataMap metaData, boolean supressWorkitemLoading) throws WorkflowException {
try {
Session jcrSession = (Session)getWorkflowSession().adaptTo(Session.class);
String simpleModelId = getSimpleModelId(model);
Node instance = this.workflowBucketManager.createWorkflowInstanceNode(jcrSession, simpleModelId, "cq:Workflow");
instance.setProperty("modelId", model.getId());
instance.setProperty("modelVersion", model.getVersion());
instance.setProperty("startTime", Calendar.getInstance());
instance.setProperty("initiator", jcrSession.getUserID()); // this is where we read the userid.
instance.setProperty("status", Workflow.State.RUNNING.name());
instance.setProperty("parentInstanceId", "none");
updateMetadata(instance, metaData, false);
instance.addNode("workItems", "nt:unstructured");
workdata.getMetaDataMap().putAll((Map)metaData);
updateWorkflowData(instance, workdata, model.getVariableTemplates());
if (WorkflowUtil.doSave((WorkflowSession)getWorkflowSession()))
jcrSession.save();
return NodeReader.createWorkflow(instance, (WorkflowSession)getWorkflowSession(), this.classLoader, this, this.customDataTypeRegistry);
} catch (RepositoryException re) {
throw new WorkflowException("Cannot create workflow instance", re);
}
}

 By using the below code you can retrieve the user name and set it instead of user id. But this is an OOTB functionality and I will not recommend to do so.

UserManager userManager = resourceResolver.adaptTo(UserManager.class);
Authorizable auth = userManager.getAuthorizable(session.getUserID());
instance.setProperty("initiator", auth.getPrincipal().getName());

 

Answers (0)