cancel
Showing results for 
Search instead for 
Did you mean: 

Java Code to trigger Custom Based Event in BO XI Release

Former Member
0 Kudos

hi,

I am new member of this community. I am very happy to be part of it. I am working in BO XI r2. I need to schedule some reports based on custom event and I need to trigger this event externally using some java application. Is it possible to trigger custom event using java code??

Need Help!.

Regards,

Yasar

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

hi Fritz,

Thanks for the reply. I have some questions regarding the code which you sent. In that code below

//Create the query to retrieve the all the events

String lQuery = "SELECT * " +

"FROM CI_SYSTEMOBJECTS " +

"WHERE SI_KIND = 'Event' " +

"ORDER BY SI_NAME";

the query is retrieving all the events, in that I want to trigger only the particular event which I am interested. For Ex I have created a event by name Test_custom in BO and I need to trigger only this event. how can I modify the query below??? and one more thing where can I find this table CI_SYSTEMOBJECTS in DB which contains info about the events?? I checked the Repository tables eight tables in DB, but i can't find this table. Need Help

Thanks & Regards,

yasar.

fritzfeltus
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Yasar,

The SYSTEMOBJECTS table does not exist in the CMS database as such, it is a virtual table which can only be queried through the Business Objects SDK.

You can find out how to use the BO Query Language here:

Developer Library home > BusinessObjects Enterprise SDK > Java developer guide > SDK Fundamentals > How do I use the query language to retrieve classes from the CMS repository?

http://devlibrary.businessobjects.com/BusinessObjectsXIR2/en/devsuite.htm

In this case, you would need to use a query such as the following:

"SELECT * FROM CI_SYSTEMOBJECTS WHERE SI_KIND = 'Event' AND SI_NAME='Test_custom'"

Cheers,

Fritz

Answers (1)

Answers (1)

fritzfeltus
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi, here is a sample.

In future, please use for Java SDK related questions, you will get a quicker response here

import com.crystaldecisions.sdk.exception.SDKException;
import com.crystaldecisions.sdk.framework.CrystalEnterprise;
import com.crystaldecisions.sdk.framework.IEnterpriseSession;
import com.crystaldecisions.sdk.framework.ISessionMgr;
import com.crystaldecisions.sdk.occa.infostore.IInfoObjects;
import com.crystaldecisions.sdk.occa.infostore.IInfoStore;
import com.crystaldecisions.sdk.plugin.desktop.event.IEvent;
import com.crystaldecisions.sdk.plugin.desktop.event.IUserEvent;


public class triggerEvent {

	public static void main(String[] args) {
		String lUser = "administrator";
		String lCMS = "servername";
		String lPWD = "";
		String lSecurity = "secEnterprise";
		IEnterpriseSession lEnterpriseSession = null;
		try {
			//Retrieve the ISessionMgr object to perform the logon
			ISessionMgr lSessionMgr = CrystalEnterprise.getSessionMgr();
			
			//Logon to Enterprise
			lEnterpriseSession = lSessionMgr.logon(lUser, lPWD, lCMS, lSecurity);

			//Retrieve the InfoStore object from the Enterprise Session
			IInfoStore lInfoStore = (IInfoStore)lEnterpriseSession.getService("", "InfoStore");

			//Create the query to retrieve the all the events
			String lQuery = "SELECT * " + 
				           "FROM   CI_SYSTEMOBJECTS " + 
						   "WHERE  SI_KIND = 'Event' " + 
						   "ORDER BY SI_NAME";
			
			IInfoObjects lInfoObjects = lInfoStore.query(lQuery);

			//Display a message if no results were returned
			if (lInfoObjects.isEmpty())
			{
				return;
			}
			
			//Go through each event returned and add it to the table
			for (int lIdx = 0; lIdx < lInfoObjects.size(); lIdx++)
			{
				//Retrieve the current event object
				IEvent oEvent = (IEvent)lInfoObjects.get(lIdx);
				IUserEvent lUserEvent = (IUserEvent) oEvent.getEventInterface();
				lUserEvent.trigger();
			}

			lInfoStore.commit(lInfoObjects);

		} catch (SDKException e) {
			e.printStackTrace();
		} finally {
			if (lEnterpriseSession!= null) {
				lEnterpriseSession.logoff();
			}
		}
	}
}