Skip to main content
7-Bedrock
Solved

How to retrieve the first Start Time of a repeated workflow activity in Windchill?

Title:
How to retrieve the first Start Time and latest Completion Time of a repeated workflow activity in Windchill?

Description:

Hi Team,

We have a requirement to retrieve the Start Date and Completed Date of a workflow activity for a Change Notice.

In certain cases, the same workflow activity can be executed multiple times due to rework or workflow routing.

The required logic is:

  • Start Date: First time the activity was started.
  • Completed Date: Last/latest time the activity was completed.

For example:

 

Activity Execution 1

Start Time : 10-NOV-2023 10:48

Completed Time : <first completion>

 

Activity Execution 2

Start Time : 12-NOV-2026 11:17

Completed Time : 12-NOV-2026 11:20

 

Expected Result:

Start Date : 10-NOV-2023 10:48

Completed Date : 12-NOV-2026 11:20

 

  • What is the recommended Windchill API or database approach to retrieve the first-ever Start Time of a workflow activity when the activity has been repeated?
  • How can we retrieve the latest Completion Time after multiple executions/rework?
  • Is WFSTATEEVENTAUDIT with TRIPCOUNT the appropriate source for this historical information?
  • Is there a supported Windchill API available for obtaining this information instead of directly querying the workflow database tables?

 

HelesicPetr
22-Sapphire II

​@Mjay 

The code for workitem or wfprocess: 

WfProcess process=null; // getTheProcessSomehow ;
WfAssignedActivity activity=null; // getTheProcessSomehow ;

NmOid nmOidprocess = new NmOid(process);
NmOid nmOidActivity = new NmOid(activity);

QueryResult status = NmWorkflowHelper.service.getRoutingStatusData(nmOidprocess);//search the task by name one by one.
QueryResult status = NmWorkflowHelper.service.getRoutingStatusData(nmOidActivity);//tasks for the activity.
while (status.hasMoreElements())
{
Object obj = status.nextElement();
if (obj instanceof WorkItem)
{
WorkItem workItem = (WorkItem) obj;
Timestamp startDate = workItem.getCreateTimestamp();
Timestamp completeDate = workItem.getModifyTimestamp();
}
}

PetrH

6 replies

Catalina
Community Manager

Hi ​@Mjay 
 
Thank you for your question.  
 
Your post has not yet received any response. I am replying to raise awareness. Hopefully, another community member will be able to help. 

Thanks, 

Translate
Catalina | PTC Community Manager
Mjay7-BedrockAuthor
7-Bedrock

Hi Catalina,

Thank you for increasing the visibility of the post.

I am still looking for technical guidance on this requirement.

Specifically, when the same workflow activity is executed multiple times due to rework, I need to retrieve:

  • Start Time: First/earliest execution of the activity
  • Completion Time: Last/latest completed execution of the activity

I would like to understand whether WFSTATEEVENTAUDIT with TRIPCOUNT is the appropriate way to identify these historical executions, or whether Windchill provides a supported Java API to retrieve this information.

Any guidance or sample API/code would be greatly appreciated.

Thanks.

Translate
HelesicPetr
22-Sapphire II

Hi ​@Mjay 

You have to retrieve all the wf activity and sort it by start date, and get the first one to get first start date and get the last activity to get competition date. 

There is no api to get it directly. You have to do it manually 

((WfAssignedActivity) effObj).getStartTime();
((WfAssignedActivity) effObj).getEndTime();

PetrH

Translate
Mjay7-BedrockAuthor
7-Bedrock

Hello ​@HelesicPetr ,

   I have a workflow activity named "Gate" with three routing options: Approve, Reject, and Rework. When Rework is selected, the workflow comes back to the same Gate activity, so it can run several times.

My requirement is to get the first-ever Start Time of the Gate activity.

What I observed:

  • WfAssignedActivity.getStartTime() returns the start time of the latest execution. The value appears to be overwritten each time the activity runs again.
  • Each execution creates a new WorkItem for the same activity.

For example:

Gate – Execution 1 → WorkItem created 10-NOV-2026 10:48

Gate – Rework → WorkItem created 12-NOV-2026 11:17

Gate – Rework → WorkItem created 15-NOV-2026 09:30

 

Expected First Start Time : 10-NOV-2026 10:48

getStartTime() returns : 15-NOV-2026 09:30

My planned approach: Query all WorkItems where source = the Gate activity, then take the earliest WorkItem creation timestamp as the first Start Time.

Translate
HelesicPetr
22-Sapphire II

​@Mjay 

The code for workitem or wfprocess: 

WfProcess process=null; // getTheProcessSomehow ;
WfAssignedActivity activity=null; // getTheProcessSomehow ;

NmOid nmOidprocess = new NmOid(process);
NmOid nmOidActivity = new NmOid(activity);

QueryResult status = NmWorkflowHelper.service.getRoutingStatusData(nmOidprocess);//search the task by name one by one.
QueryResult status = NmWorkflowHelper.service.getRoutingStatusData(nmOidActivity);//tasks for the activity.
while (status.hasMoreElements())
{
Object obj = status.nextElement();
if (obj instanceof WorkItem)
{
WorkItem workItem = (WorkItem) obj;
Timestamp startDate = workItem.getCreateTimestamp();
Timestamp completeDate = workItem.getModifyTimestamp();
}
}

PetrH

Translate
Mjay7-BedrockAuthor
7-Bedrock

Hi @HelesicPetr, thank you for the detailed guidance and sample code.

 This is really helpful and provides exactly the approach I needed to retrieve the WorkItems and determine the first start time of the repeated Gate activity.

 

 

Translate