Skip to Content
0

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

May 26, 2017 at 02:16 PM

128

avatar image
Former Member

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.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

4 Answers

Joe Peters May 31, 2017 at 04:29 PM
1

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$");
}
Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member May 30, 2017 at 11:17 PM
0

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 ?

Share
10 |10000 characters needed characters left characters exceeded
Bharath B N
May 30, 2017 at 12:04 AM
0

Try by replacing with this line

IReportBase oReport = (IReportBase)InfoObject;

in the place of

IReport oReport = (IReport)InfoObject;

- Bharath

Share
10 |10000 characters needed characters left characters exceeded
Bharath B N
May 31, 2017 at 01:48 AM
0

Not possible with REST SDK.

No APIs available for this workflow.

Share
10 |10000 characters needed characters left characters exceeded