Expand my Community achievements bar.

Enhance your AEM Assets & Boost Your Development: [AEM Gems | June 19, 2024] Improving the Developer Experience with New APIs and Events
SOLVED

Right permission to write property on workflow instance (WF_model_instance/data/metaData)

Avatar

Level 4

Dear community,

 

I use the code (in WorkflowProcess) below to write a value on the workflow instance.

if (!filePath.isBlank()) {
    workItem.getWorkflowData().getMetaDataMap().put("filePath", filePath);
}

It seems that the permission of previous participant matters here.

If I use admin on previous participant step, the code works, but not for other custom users.

 

I've tried adding "jcr:write", "rep:write" permissions on the custom user, but they don't work in this case.

Could anyone told me what's the right permission to set, or I should includ the custom user into certain group?

 

Thanks! 

 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

@YuSheng We facing similar issue in one of the project. It was resolved by getting the user session from below code and also making sure that the user access to the payload path

 

String payloadPath = workItem.getWorkflowData().getPayload().toString();
        ResourceResolver resolver = wfsession.adaptTo(ResourceResolver.class);
        Resource res = resolver.getResource(payloadPath);
        Session session = resolver.adaptTo(Session.class);

 

And also make sure that he is part the workflow users group

View solution in original post

4 Replies

Avatar

Community Advisor

@YuSheng Did you try providing the write permissions to /var/workflow/instances/ folder?

Avatar

Level 4

Hi @Shashi_Mulugu 

Do you mean providing write permission to the user I created?

Yes I did try adding "jcr:write" permission on it.

 

The workflow process is like

1. dialog participant step (upload file and set the path to payload)

2. process step (fetch the path in payload and write it on instance metadata)

 

If I set participant user in first step to administrator, the process step can successfully write(put) the property on wf instance, but if the participant user is not in administrator group, the second step doesn't work.

Since it's not possible to set the user as administrator, I suppose I need the right permission for the custom user to make it work.

Avatar

Correct answer by
Community Advisor

@YuSheng We facing similar issue in one of the project. It was resolved by getting the user session from below code and also making sure that the user access to the payload path

 

String payloadPath = workItem.getWorkflowData().getPayload().toString();
        ResourceResolver resolver = wfsession.adaptTo(ResourceResolver.class);
        Resource res = resolver.getResource(payloadPath);
        Session session = resolver.adaptTo(Session.class);

 

And also make sure that he is part the workflow users group

Avatar

Level 4

I found the problem, the custom user doesn't actually successfully write the property onto payload. So the second step surely get nothing from payload.

It is about the right permission to set content/proj... (payload), not the instance.

 

Sorry for the misleading information I provided, and big thanks to @Jagadeesh_Prakash @Shashi_Mulugu for the help.

Will mark @Jagadeesh_Prakash 's answer as correct reply.