Highlighted

Invoke the Workflow Actions using API(UI clicks)

Avatar

Avatar

umamaheswariy46

Avatar

umamaheswariy46

umamaheswariy46

24-04-2019

Hi Team,

By clicking the buttons on the UI we have to do the WF actions.

I am trying to use the WF API to do this.

Is there any way that I can get the WF Running instance details based on the content URL.

Please advice.

Thanks

Uma

Replies

Highlighted

Avatar

Avatar

Gaurav-Behl

MVP

Total Posts

1.1K

Likes

226

Correct Answer

281

Avatar

Gaurav-Behl

MVP

Total Posts

1.1K

Likes

226

Correct Answer

281
Gaurav-Behl
MVP

24-04-2019

I doubt that but I could be wrong, if its a transient instance then the processing is in memory. Otherwise, it might be stored temporarily under /var but may not be in a processable format

Highlighted

Avatar

Avatar

smacdonald2008

Total Posts

12.7K

Likes

1.4K

Correct Answer

2.3K

Avatar

smacdonald2008

Total Posts

12.7K

Likes

1.4K

Correct Answer

2.3K
smacdonald2008

24-04-2019

As Gaurav states - OOTB - this is not supported. However - you can look at invoking a WF from a servlet that gets called when you click a given Button in the AEM UI.

Highlighted

Avatar

Avatar

umamaheswariy46

Avatar

umamaheswariy46

umamaheswariy46

24-04-2019

I am able to move the WF from one state to another state by using the WF API with one problem.

By using getAdmistrativeResourceSolver I am able to get all the WF sessions based on WF states.

By using the ServiceUser I am not getting any WF sessions based on state or workItems.

Here is what I am using

Working

ResourceResolver rsreolover=resolverFactory.getAdministrativeResourceResolver(null); (depricated)

session=rsreolover.adaptTo(Session.class);

WorkflowSession wfsession=workflowservice.getWorkflowSession(session) ;

Workflow[] wf=wfsession.getWorkflows("RUNNING");

Not working

ResourceResolver rsreolover=resolverFactory.getServiceResourceResolver(param);

session=rsreolover.adaptTo(Session.class);

WorkflowSession wfsession=workflowservice.getWorkflowSession(session) ;

Workflow[] wf=wfsession.getWorkflows("RUNNING");

Why the service user is not working. How to fix it?

Thanks

Uma

Highlighted

Avatar

Avatar

smacdonald2008

Total Posts

12.7K

Likes

1.4K

Correct Answer

2.3K

Avatar

smacdonald2008

Total Posts

12.7K

Likes

1.4K

Correct Answer

2.3K
smacdonald2008

25-04-2019

You should use Workflow session.

Highlighted

Avatar

Avatar

Arun_Patidar

MVP

Total Posts

2.9K

Likes

958

Correct Answer

820

Avatar

Arun_Patidar

MVP

Total Posts

2.9K

Likes

958

Correct Answer

820
Arun_Patidar
MVP

25-04-2019

Hi Uma,

You can get WF instances of current page using resource ststus utility

http://localhost:4504/resource-status/editor/<CurrentPage>.2.json?_=1556182853449

e.g.

http://localhost:4504/resource-status/editor/content/AEM64App/en.2.json?_=1556182853449

Get workflow instance and pass to servlet using parameter and get subservice session and adapt to workflow Instance

try {

paramMap.put(ResourceResolverFactory.SUBSERVICE, "readService");

resourceResolver = resourceFactory.getServiceResourceResolver(paramMap);

Session session = resourceResolver.adaptTo(Session.class);

try {

if (session.isLive()) {

response.getWriter().println("Session User is " + session.getUserID());

WorkItem wi = resourceResolver.getResource(

"/var/workflow/instances/server0/2019-04-25/approval_workflow_1/workItems/node1_var_workflow_instances_server0_2019-04-25_approval_workflow_1")

.adaptTo(WorkItem.class);

response.getWriter()

.println("********************* WORKFLOW Current Assingee: " + wi.getCurrentAssignee());

Workflow wf = wi.getWorkflow();

response.getWriter()

.println("*********************Is This WORKFLOW still Active: " + wf.isActive());

}

} catch (Exception e) {

response.getWriter().println("Exception");

} finally {

session.logout();

}

1739839_pastedImage_0.png

Highlighted

Avatar

Avatar

umamaheswariy46

Avatar

umamaheswariy46

umamaheswariy46

25-04-2019

Thanks for the info related to Resource Status (liked it) Utility but seems like resource status works only for the editors which are like pages,XF .. Is there any way that I can get these details for the assets as well.

Is there way that we can get the same info on the Assets as well?

and I am getting Null when I use this

WorkItem wf = resourceResolver.getResource("/var/workflow/instances/server0/2019-04-22_1/aem-xxxx-publish-workflow_323/workItems/node1_var_workflow_instances_server0_2019-04-22_1_aem-xxxx-publish-workflow_323").adaptTo(WorkItem.class) 

WorkFlow wf = resourceResolver.getResource("/var/workflow/instances/server0/2019-04-22_1/aem-xxxx-publish-workflow_323/").adaptTo(WorkFlow.class)

Both are returning null.

Thanks

Highlighted

Avatar

Avatar

umamaheswariy46

Avatar

umamaheswariy46

umamaheswariy46

25-04-2019

I have used WorkflowSession in my example but with admin user ,. WFsession is returning Null if I use the "serviceUser" 

Thanks