on 05-26-2017 3:16 PM
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.
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$");
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Not possible with REST SDK.
No APIs available for this workflow.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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 ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Try by replacing with this line
IReportBase oReport = (IReportBase)InfoObject;
in the place of
IReport oReport = (IReport)InfoObject;
- Bharath
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.