cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - You can subscribe to a forum, label or individual post and receive email notifications when someone posts a new topic or reply. Learn more! X

Need the ability to invoke ChangeLifecycleStateSummaryEvent or LifecycleServiceEvent.STATE_CHANGE from custom code

Need the ability to invoke ChangeLifecycleStateSummaryEvent or LifecycleServiceEvent.STATE_CHANGE from custom code

CAT Service is trying to use the Notifications in Windchill to email users when a Media goes from "IN WORK" to "PRODUCTION" state using a Change Notice.  However from the custom Service workflow we cannot emit ChangeLifecycleStateSummaryEvent or LifeCycleServiceEvent.STATE_CHANGE for an object from the custom code.

note from Marek Nowacryk -
"I investigated this further and unfortunately that will not be possible as the methods that will have to be used to emit ChangeLifecycleStateSummaryEvent or LifeCycleServiceEvent.STATE_CHANGE for an object: 
getSummaryEvent and contribute  in ChangeLifecycleStateSummaryEvent and generateEventKey in  LifeCycleServiceEvent are currently not supported for use in customizations: "

We need to have this supported in our custom workflow so the users can get their Notification emails when the Media goes to Production state.

ChangeLifecycleStateSummaryEvent.getSummaryEvent().contribute((Notifiable)object, oldState, newState);


LifeCycleServiceEvent.generateEventKey(LifeCycleServiceEvent.STATE_CHANGE));



6 Comments
PradeepRao
5-Regular Member

One easier option here is to modify the workflow and create a sync robot that listens to the STATE_CHANGE event on the desired object. You could then have that drive a routing option that leads to a path with a Notification robot. Is there a reason to not use this approach?

jdarlington
1-Newbie

I did not know you can do this.  Do you have any examples on how to set it up?  Not too familiar with changing workflow or creating routing options. Thanks!

PradeepRao
5-Regular Member

The Windchill customization guide has additional details on workflow templates.and routing options.

Below is a simplified example of a Synchronize robot that would send an email on the state of the primary business object getting changed.

simpleSyncExample.png

This Synchronize robot has been customized with a single routing option. The Routing Expression is executed when the STATE_CHANGE event is emitted for the primary business object. TA simple routing expression has been coded to set the result to the desired routing event.

In this example, the Synchronize robot starts and waits until such time that the primary business object changes state. Thereupon it executes the routing expression which in turn activates the link titled sendEmail and triggers the Notification robot. The Notification robot would need to be customized to specify the mail recipients and the subject and content of the email.

syncRobotDetails.png

linkActivation.png

Please note that this is a contrived example and is intended to demonstrate the use of the Synchronize robot and Routing Events. You can use the Routing Expression to programmatically select between multiple routing events and decide execution paths at run time.

Note however, that if in your template, the state is set through a Set State robot, you have a simpler option, you can achieve the desired behavior by simply adding a notification robot immediately succeeding the Set State robot.

jdarlington
1-Newbie

So how would I do it for Life Cycle state changing to production?  We have a set state robot in the workflow but I don't know what that is for.  It just says

primaryBusinessObject. 

PradeepRao
5-Regular Member

The primary business object is the object that the workflow has as the primary object of interest. For example, a review process could have a document as its primary business objects.


The following explanations assume that the primary object is the object that you would like to be notified on when its state changes to 'Production'.


In your scenario, would you expect the state change to happen solely through the Set State robot or is there a possibility that the state change happens through any other means? And if the state change happens through other means, do you still need the notification?

If the expectation is that notifications be sent only for a state change to 'Production' that happens through the Set State robot (and not through other means), you could have an expression robot following the Set State robot and code a java expression within that expression robot to evaluate if the state of the primary business object is now 'Production'. If it is, you could route execution down a path that includes a Notification robot. If not, you could route execution along a path that skips the Notification robot.

If you require notifications to be sent irrespective of how the primary business object changed its state to 'Production', then you could devise a solution that incorporates a sync robot like explained in the previous example. In your case, the expression would be check to see if the state of the primary business object is 'Production' before activating the sendEmail link. Please note that using a sync robot has some performance penalty as compared to a simple expression robot.

olivierlp
Community Manager
Status changed to: Archived

Hello,

We are archiving your idea as part of a general review. This action is based on the age of your idea and the total number of votes received, as per this announcement.

You can always post a new idea with all the details required in the form.

Thank you for your participation.