cancel
Showing results for 
Search instead for 
Did you mean: 

How to update crystal report recurrance db logon information using java sdk

former_member244450
Participant
0 Kudos

Hello Everyone, We recently had a major change in process that db teams would be changing account passwords once in every year. We mostly have crystal reports running. On search, "Schedule Manager" really saved us in updating logon details in bulk for crystal.

Challenge: Now, the report would have the correct logon details, but the recurrances would still be referring to old creds and they would fail. We have tried the below code and were able to update the recurrences db userid and pwd provided the format type of recurrence should be set to ONLY CRYSTAL. For any other format type like excel or pdf, my code fails.

Code:

IInfoStore infoStore =

(IInfoStore) enterpriseSession.getService("InfoStore");

String query = "select * from CI_INFOOBJECTS "

+ "where SI_PARENTID=421724 AND SI_RECURRING=1 AND SI_SCHEDULE_STATUS=9";

IInfoObjects infoObjects = (IInfoObjects) infoStore.query(query);

InfoObject = (IInfoObject) infoObjects.get(0);

//cast the InfoObject as a Report Object

IReport oReport = (IReport)InfoObject;

IReportLogon rptLogon = (IReportLogon) oReport.getReportLogons().get(0);

String usrname= rptLogon.getUserName();

System.out.println(usrname);

rptLogon.setUserName("bo_rept");

rptLogon.setPassword("rept4bo$");

infoStore.commit(infoObjects);

System.out.println("Report username" + "Updated Successfully!!!");

This code errors out when recurrence type is Excel. Error:

Exception in thread "main" java.lang.ClassCastException: com.sun.proxy.$Proxy0 cannot be cast to com.crystaldecisions.sdk.plugin.desktop.report.IReport

at CrystalDBUpdatev1.main(CrystalDBUpdatev1.java:43)

Please help here!! Very soon my environment would see lots of scheduled failures. Environment: 4.2 SP3 Servers: Windows 2012 Tomcat 8.

Accepted Solutions (0)

Answers (4)

Answers (4)

Joe_Peters
Active Contributor

I just answered a surprisingly similar question on BOB. A static type (Pdf, Excel) can't be cast to IReport. You need to get the IReportProcessingInfo object from IContent.

Untested, but the following should get you started.

for(Object o : infoObjects)
{
	IReportProcessingInfo proc;
	
	if(o instanceof IReport)
		proc =  ((IReportProcessingInfo)o);
	else
		proc = (IReportProcessingInfo) ((IContent)o).getPluginProcessingInterface(IReport.KIND);


	IReportLogon rptLogon = (IReportLogon) proc.getReportLogons().get(0);
	String usrname= rptLogon.getUserName();
	System.out.println(usrname);
	rptLogon.setUserName("bo_rept");
	rptLogon.setPassword("rept4bo$");
}
former_member230921
Active Contributor
0 Kudos

Not possible with REST SDK.

No APIs available for this workflow.

former_member244450
Participant
0 Kudos

Hi Bharath, I tried but no luck. Error is:

Exception in thread "main" java.lang.ClassCastException: com.sun.proxy.$Proxy0 cannot be cast to com.crystaldecisions.sdk.plugin.desktop.report.IReportBase

Any other pointers? I saw your blogs on RESTAPI. Do you think its possible with REST API ?

former_member230921
Active Contributor
0 Kudos

Try by replacing with this line

IReportBase oReport = (IReportBase)InfoObject;

in the place of

IReport oReport = (IReport)InfoObject;

- Bharath