While trying to update a document properties using the restful API I cannot change the ownerid.
This is the result of my get request:
<entry>
<title type="text">document</title>
<updated>2018-03-29T10:56:51.939Z</updated>
<content type="application/xml">
<attrs>
<attr name="cuid" type="string">AWkFvt1UNShIqwJqu3U6pts</attr>
<attr name="keywords" type="string" />
<attr name="parentcuid" type="string">AaWFM3xI6bxBv9HlI5RIuyw</attr>
<attr name="created" type="string">Mar 27, 2018 5:22 PM</attr>
<attr name="name" type="string">New Document_test</attr>
<attr name="description" type="string" />
<attr name="id" type="string">12670</attr>
<attr name="type" type="string">Webi</attr>
<attr name="ownerid" type="int32">12</attr>
<attr name="updated" type="string">Mar 29, 2018 11:56 AM</attr>
<attr name="parentid" type="string">7018</attr>
</attrs>
</content>
</entry>
When trying to change the ownerid in a put request:
<title type="text">document</title>
<updated>2018-03-29T10:56:51.939Z</updated>
<content type="application/xml">
<attrs>
<attr name="cuid" type="string">AWkFvt1UNShIqwJqu3U6pts</attr>
<attr name="keywords" type="string" />
<attr name="parentcuid" type="string">AaWFM3xI6bxBv9HlI5RIuyw</attr>
<attr name="created" type="string">Mar 27, 2018 5:22 PM</attr>
<attr name="name" type="string">New Document_test</attr>
<attr name="description" type="string" />
<attr name="id" type="string">12670</attr>
<attr name="type" type="string">Webi</attr>
<attr name="ownerid" type="int32">12133</attr>
<attr name="updated" type="string">Mar 29, 2018 11:56 AM</attr>
<attr name="parentid" type="string">7018</attr>
</attrs>
</content>
</entry>
As a result the ownerid doesn't change.
But when trying the same thing sing a java SDK code the ownerid does change.
Here is the code:
import com.crystaldecisions.sdk.properties.*;
import com.businessobjects.qaaws.internal.ISessionMgr;
import com.crystaldecisions.sdk.exception.SDKException;
import com.crystaldecisions.sdk.framework.CrystalEnterprise;
import com.crystaldecisions.sdk.framework.IEnterpriseSession;
import com.crystaldecisions.sdk.occa.infostore.IInfoStore;
import com.crystaldecisions.sdk.occa.infostore.CePropertyID;
import com.crystaldecisions.sdk.occa.infostore.IInfoObject;
import com.crystaldecisions.sdk.occa.infostore.IInfoObjects;
import com.crystaldecisions.sdk.plugin.desktop.program.IProgramBaseEx;
public class Owner
{
public static void main(String[] args) throws Throwable{
com.crystaldecisions.sdk.framework.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 = "test_Prefe";
String query = "select si_name, si_id from ci_systemobjects where si_kind = 'user' and si_name='" + 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_NAME = 'New Document_test'");
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();
}
}
BI 4.2 Support Pack 4 Patch 2
I would suggest opening an incident with SAP. I can't think of any legitimate reason why the PUT call could not update the owner ID.