The example of using the SaveObjectAs operation to overwrite one repository object with another. The request contains a source object moniker and description of the object, which contents must be overwritten. The response contains description of the object, the content of which is overwritten.
{
"SaveObjectAs" :
{
"tObject" :
{
"id" : "S1!M!176019"
},
"tArg" :
{
"destination" :
{
"operation" : "OverwriteExisting",
"overwrite" :
{
"object" :
{
"@isShortcut" : "false",
"@isLink" : "false",
"@hf" : "false",
"i" : "REPORT_COPY",
"n" : "Regular report(Copy)",
"k" : "176178",
"c" : "2562",
"p" : "65",
"h" : "false",
"hasPrv" : "false",
"ic" : "false"
}
},
"autoGenerateName" : "true"
}
}
}
}
{
"SaveObjectAsResult" :
{
"object" :
{
"@ds" : "",
"@isShortcut" : "0",
"@isLink" : "0",
"@ver" : "2",
"@hf" : "0",
"i" : "REPORT_COPY",
"n" : "Regular report(Copy)",
"k" : "176178",
"c" : "2562",
"p" : "65",
"h" : "0",
"hasPrv" : "0",
"ic" : "0",
"obId" :
{
"id" : "S1!M!176178"
}
}
}
}
The OverwriteObj function specified below overwrites the content of one object with the the content of another object of the repository. Identifiers of source object and destination object are sent by means of the sourcedObj and destinationObj input parameters. This example uses the FindObjectById function. Code of this function see in the example Get Description of Object by Its Identifier. The result of the operation is the result of the function.
public static SaveObjectAsResult OverwriteObj(MbId mb, string sourcedObj, string destinationObj)
{
var somClient = new SomPortTypeClient(); //Proxy object for operation execution
//Operation execution parameters
var tSave = new SaveObjectAs()
{
tArg = new SaveObjectAsArg()
{
destination = new ObjectCopyInfo()
{
//Action - rewrite existing object
operation = ObjectCopyOperation.OverwriteExisting,
overwrite = new ObjectOverwriteInfo()
{
//Rewritable object
@object = FindObjectById(mb, destinationObj)
}
}
},
tObject = new OdId()
{
id = mb.id + "!" + FindObjectById(mb, sourcedObj).k
}
};
//Rewrite object
var result = somClient.SaveObjectAs(tSave);
return result;
}
See also: