Skip to Content
0
Jan 31, 2012 at 09:52 AM

Chnage Report Owner

531 Views

Hi Forum Members

I saw this in Sap Ideas List Is any of the forum members develop any code and try this..

This is the one i saw in web

-


When a users leaves the company, we need to transfer ownership of all reports to another user. In our security model, non-admin users do not have the right to modify a report for which they are not they owner. Also, we get a number of users that change their name (married, divorced.. other). Currently, we have to copy all reports owned by their "Old" name into a folder, then they have to use their "new" name/userid to perform "Save As" for each one of them. This is VERY time consuming as we have users with dozens and even hundreds (power users) of reports. I get this request 30-50 times a year.

When a user is removed from the system, all public folder reports become owned by Administrator. So some of the code for this has already exists. THIS WOULD BE AWESOME FUNCTIONALITY!! I have spoken with many other BO admins that have this as one of the top 5 on their wish list.

-


I find some code on Bo forum , but when irun it didnt give any error but it didnnt do any this.

I comile this java to jar and call this jar file through Cmc console as a program file and schedule it.

It say success but it didnt change the owner of the report If some one have an idea chanck this code

-


package com.programobject;

import com.crystaldecisions.sdk.properties.*;

import com.crystaldecisions.sdk.exception.SDKException;

import com.crystaldecisions.sdk.framework.IEnterpriseSession;

import com.crystaldecisions.sdk.occa.infostore.IInfoStore;

import com.crystaldecisions.sdk.occa.infostore.IInfoObject;

import com.crystaldecisions.sdk.plugin.desktop.program.IProgramBaseEx;

public class JavaProgramObject_1 implements IProgramBaseEx

{

public void run(IEnterpriseSession enterpriseSession,IInfoStore infoStore,IInfoObject programInfoObject,java.lang.String objectID,java.lang.String[] args) throws SDKException

public class OwnerChanger {

public static void main(String[] args) throws Throwable{

ISessionMgr sm = CrystalEnterprise.getSessionMgr();

// args[] contains user, password, CMS host name and authentication type

IEnterpriseSession es = sm.logon(args[0], args[1], args[2], args[3]);

IInfoStore infoStore = (IInfoStore)es.getService("InfoStore");

// Get the ID of the new owner

String newOwnName = "kaboorva";

String query = String.format("select si_name, si_id from ci_systemobjects where si_kind = 'user' and si_name like '%kttao%'", newOwnName);

IInfoObject newOwner = (IInfoObject)infoStore.query(query).get(0);

int newOwnerId = newOwner.getID();

// Query for the objects whose ownership should be changed

IInfoObjects objsToChange = infoStore.query("select si_id, si_name, si_owner, si_ownerid from ci_infoobjects where SI_KIND='webi' and SI_OWNER = 'testy' and SI_INSTANCE=0");

for (Object o : objsToChange ) {

IInfoObject objToChg = (IInfoObject)o;

String oldOwner = objToChg.properties().getString(CePropertyID.SI_OWNER);

// Set new owner ID. Note that changing CePropertyID.SI_OWNER has no effect; SI_OWNERID must be changed instead

objToChg.properties().setProperty(CePropertyID.SI_OWNERID, newOwnerId);

System.out.format("Changed owner on %s: %s -> %s%n", objToChg.getTitle(), oldOwner, newOwnName);

}

System.out.println("Saving changes...");

infoStore.commit(objsToChange);

System.out.println("Complete");

infoStore = null;

es.logoff();

}

}

-


Regards