Quantcast
Channel: PTC Community: Message List - Windchill
Viewing all articles
Browse latest Browse all 8876

Re: How to create a subscription to object events into a worklow ?

$
0
0

Following code works for 9.1 M40.

 

void constructSubscription(Notifiable targetObject) throws WTException, WTPropertyVetoException{

    //Declare and initialize NotificationSubscription variable

    NotificationSubscription subscriptionAttributes = new NotificationSubscription();

   

    //set attributes for subscriptionAttributes

    subscriptionAttributes.setName("My Custom Subscription Name");

    subscriptionAttributes.setSubject("My Custom Subscription Subject");

    subscriptionAttributes.setMessage("My Custom Subscription Message");

    subscriptionAttributes.setSendImmediate(true);

 

    //create Map for events. Events are case sensitive.

    //Capitalize all characters and add "_" (underscore) between words

    //Here is list of a few events

    //CHECK_IN_FROM_PROJECT, CHECK_OUT_IN, COPY, DELETE,

    //EDIT_ACCESS_CONTROL, EDIT_ATTRIBUTES, EDIT_IDENTITY, MARKUP,

    HashMap<String,WTStringMap> eventsMap = new HashMap<String,WTStringMap>();

    eventsMap.put("CHECK_OUT_IN", (WTStringMap)null);

    eventsMap.put("DELETE", (WTStringMap)null);

   

    //get subscriber, currently setting to session user

    NotifySubscriptionRecipient subscriber = NotifySubscriptionRecipient.newNotifySubscriptionRecipient(SessionHelper.getPrincipal(), NotifySubscriptionRecipient.TO_ADDRESS);

 

    //create subscription

    NotificationHelper.manager.createObjectSubscription(subscriptionAttributes,subscriber, targetObject, eventsMap, true);

}


Viewing all articles
Browse latest Browse all 8876

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>