cancel
Showing results for 
Search instead for 
Did you mean: 

IInfoObjects .add throws UnsupportedOperationException

Former Member
0 Kudos

Hi,

I try to use the IInfoStore schedule method for scheduling a report. It is a simple report with no paramters and forumulas.

But I receive an UnsupportedOperationException, when I try to add the IReport object into the IInfoObjects list.

I used the sdk scheduling example as template:

...
IReport report  = (IReport) infoObject;
ISchedulingInfo scheduleInfo = report.getSchedulingInfo();
scheduleInfo.setType(CeScheduleType.ONCE);
scheduleInfo.setRightNow(true);
IReportFormatOptions reportFormatOptions = ((IReport) report).getReportFormatOptions();
reportFormatOptions.setFormat(IReportFormatOptions.CeReportFormat.PDF);
IInfoObjects objectsToSchedule = infostore.newInfoObjectCollection();
objectsToSchedule.add(report); // throws UnsupportedOperationException
infostore.schedule(objectsToSchedule);

Can anybody help?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Toni,

For scheduling you can try using this code snippet

String query ="SELECT * FROM CI_INFOOBJECTS WHERE SI_KIND='CrystalReport' AND SI_INSTANCE=0 AND SI_Name='Report Name'";

	IInfoObjects infoobjects =(IInfoObjects) infostore.query(query);

	IInfoObject infoobject =(IInfoObject) infoobjects.get(0);

	IReport reportObj=(IReport) infoobject;

	ISchedulingInfo schedulinginfoObj=infoobject.getSchedulingInfo();

	schedulinginfoObj.setRightNow(true);

	schedulinginfoObj.setType(CeScheduleType.ONCE);

	infostore.schedule(infoobjects);

Let me know if this was helpful.

Regards,

Prithvi

Former Member
0 Kudos

Hi Prithvi,

thanks for your answer. The way how you schedule the report works fine. The report is available in my CMC now.

Thanks

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Toni,

Please try below sample code :-

try
{
	ISessionMgr sm = CrystalEnterprise.getSessionMgr();
	IEnterpriseSession enterpriseSession = sm.logon(username, password, CMS, Authen);

  IInfoStore infostore = (IInfoStore)enterpriseSession.getService("InfoStore");  
  IInfoObjects infoObjects = infostore.query("Select SI_PROCESSINFO.SI_PROMPTS "
    + "From CI_INFOOBJECTS Where SI_KIND='CrystalReport' and "
    + "SI_NAME='World Sales Report' and SI_INSTANCE=0"); 
  IInfoObject report = (IInfoObject) infoObjects.get(0);

  ISchedulingInfo scheduleInfo = report.getSchedulingInfo();      
  scheduleInfo.setType(CeScheduleType.ONCE);
  scheduleInfo.setRightNow(true);
        
  IReportFormatOptions reportFormatOptions = ((IReport)report).getReportFormatOptions();
  reportFormatOptions.setFormat(IReportFormatOptions.CeReportFormat.CRYSTAL_REPORT);
  
  IReportPrinterOptions printerOptions = ((IReport)report).getReportPrinterOptions();
  printerOptions.setCopies(1);
       
  IInfoObjects objectsToSchedule = infostore.newInfoObjectCollection();
  objectsToSchedule.add(report);
  infostore.schedule(objectsToSchedule);
}
catch(Exception e)
{
out.println(e.getMessage());
}

Let me know if you need any information

Regards,

Rameez