Skip to main content
12-Amethyst
June 12, 2026
Solved

Windchill workflow customization

  • June 12, 2026
  • 4 replies
  • 84 views

Is it possible to complete a workflow task programmatically using Java code?

For example, I would like to complete a Change Notice task programmatically rather than through the user interface. Is this supported? If so, could you please provide some guidance on how this can be achieved?

 

Best Regards,

Shrikant Bhosle

Best answer by Summer

@Shrikant Bhosle 

Sample code:

                   WorkItem workItem = (WorkItem) persistable;
                    WTPrincipalReference user;
                    String routId;
                    WfActivity wfActivity = (WfActivity) workItem.getSource().getObject();
                    WfProcess wfProcess = wfActivity.getParentProcess();
                    // check activity if complete.
                    if (!workItem.isComplete()) {
                        // complete workitem                      
                        String comments = "";
                        List<String> eventList = new ArrayList<String>();
                        eventList.add(routId);
                        WorkflowHelper.service.workComplete(workItem, user, CollectionUtil.toVector(eventList));
                        WfEventHelper.createVotingEvent(null, wfActivity, workItem, user, comments,CollectionUtil.toVector(eventList),false, workItem.isRequired());
                        wfProcess = (WfProcess) PersistenceHelper.manager.refresh(wfProcess);
                    }

4 replies

12-Amethyst
June 12, 2026

 

17-Peridot
June 12, 2026

Hi ​@Shrikant Bhosle ,

What is the business use case for this requirement?

17-Peridot
June 12, 2026

Hi ​@Shrikant Bhosle,

Please refer to the API below.

		WorkflowHelper.service.completeActivity(wfActivity, wfProcess, string, principalReference, string);

 

Summer16-PearlAnswer
16-Pearl
June 15, 2026

@Shrikant Bhosle 

Sample code:

                   WorkItem workItem = (WorkItem) persistable;
                    WTPrincipalReference user;
                    String routId;
                    WfActivity wfActivity = (WfActivity) workItem.getSource().getObject();
                    WfProcess wfProcess = wfActivity.getParentProcess();
                    // check activity if complete.
                    if (!workItem.isComplete()) {
                        // complete workitem                      
                        String comments = "";
                        List<String> eventList = new ArrayList<String>();
                        eventList.add(routId);
                        WorkflowHelper.service.workComplete(workItem, user, CollectionUtil.toVector(eventList));
                        WfEventHelper.createVotingEvent(null, wfActivity, workItem, user, comments,CollectionUtil.toVector(eventList),false, workItem.isRequired());
                        wfProcess = (WfProcess) PersistenceHelper.manager.refresh(wfProcess);
                    }