Skip to Content
0
Jun 18, 2015 at 10:07 AM

Set "Use same database logon as when report is run" from SDK

105 Views

Hi,

Is it possible to change the setting mentioned in the title via Java SDK?

Currently I am able to change it via CMC.

I found an example which has IReportLogon.setPromptOnDemandViewing(boolean promptOnDemand), the description of this method seems to be what I am looking for, however it doesn't change the setting after running the code below, everything else seems to have updated when I checked the report's Database Configuration on CMC. There is no error.

public static void changeDatabaseConfiguration(String reportName) {
  IEnterpriseSession enterpriseSession=null;
  try {
  enterpriseSession=getEnterpriseSession();

  IInfoStore infoStore=(IInfoStore)enterpriseSession.getService("InfoStore");
  IInfoObjects infoObjects=infoStore.query("SELECT * FROM CI_INFOOBJECTS WHERE SI_INSTANCE=0 and si_kind='CrystalReport'");

  IInfoObject infoObject=null;
  for (int i=0; i<infoObjects.size(); i++) {
  infoObject=(IInfoObject)infoObjects.get(i);
  if (infoObject.getTitle().equalsIgnoreCase(reportName)&&infoObject.getParent().getTitle().equalsIgnoreCase(CRS_USER_ID)) {
  IReport rep=(IReport)infoObject;
  ISDKList boReportLogons=rep.getReportLogons();
  IReportLogon boReportLogon=(IReportLogon)boReportLogons.get(0);
  boReportLogon.setOriginalDataSource(false);
  boReportLogon.setCustomServerType(CeReportServerType.ORACLE);
  boReportLogon.setCustomServerName(CRS_USER_ID);
  boReportLogon.setCustomUserName(DB_USER_ID);
  boReportLogon.setCustomPassword(DB_USER_PASSWORD);
  boReportLogon.setPromptOnDemandViewing(false);
  infoStore.commit(infoObjects);
  }
  }


  } catch (Exception e) {
  e.printStackTrace();
  } finally {
  if (enterpriseSession!=null) {
  enterpriseSession.logoff();
  }
  }
}