Thank you for your suggestions. AS @JIE ZHANG suggested I tried the InstanceSubscription.
Subscription subscription = Factory.InstanceSubscription.createInstance(os, null);
subscription.set_DisplayName(subscriptionName);
subscription.set_EventAction(eventAction.retrieveEventActionByName(moduleInfo.event_action_name));
subscription.set_IsEnabled(true);
subscription.set_IsSynchronous(true);
com.filenet.api.admin.ClassDefinition classDefinition = Factory.ClassDefinition.getInstance(os, new Id("{E332627C-02F2-4EF8-ABC4-3A48458AD2C2}"));
subscription.set_SubscriptionTarget(classDefinition);
SubscribedEventList eventList = Factory.SubscribedEvent.createList();
Id subscribedEventId = GuidConstants.Class_CreationEvent;
EventClassDefinition eventClassDefinition = Factory.EventClassDefinition.getInstance(os, subscribedEventId);
SubscribedEvent subscribedEvent = Factory.SubscribedEvent.createInstance();
subscribedEvent.set_EventClass(eventClassDefinition);
eventList.add(subscribedEvent);
subscription.set_SubscribedEvents(eventList);
subscription.save(RefreshMode.REFRESH);
Doing so works ok but not as I wanted. What i want to achieve is that the type is "Applies to all objects of this class". However the code above created a subscription type "Applies to this instance of this class...".
How can I specify the subscription type when creating the subscription?
Thanks indeed.
------------------------------
Kevin Sheng
------------------------------
Original Message:
Sent: Tue January 02, 2024 05:27 AM
From: Gabriela Maráková
Subject: Create Subscription Programmatically
Subscription
is the base class for subclasses defined with specialized behavior. You can create objects for the subclasses, but you cannot create a base Subscription
object.
So you can create only subscriptions with Factory.ClassSubscription/ClassWorkflowSubscription/CmThumbnailGenerationSubscription/InstanceSubscription/InstanceWorkflowSubscription
------------------------------
Gabriela Maráková
Original Message:
Sent: Fri December 29, 2023 11:28 AM
From: Kevin Sheng
Subject: Create Subscription Programmatically
I am trying to create FileNet P8 Subscription programmatically but no success.
Unlike the EventAction creation code below, Subscription creation does not work and I am unable to use P8 Java API to create P8 Subscription programmatically. I am using CPE JACE 5.5.8 JAR.
EventAction eventAction = Factory.EventAction.createInstance(os, null)
Subscription subscription = Factory.Subscription.createInstance(os, null);
This line of code above does not compile and the method createInstance does not exist.
Your suggestion is appreciated in advance.
Thanks,
Kevin
------------------------------
Kevin Sheng
------------------------------