Creating an Object

Below is the example of using the CreateObject operation to create a repository object. The request contains basic information required to create an object: identifier, name and object class identifier. Also, the created object is indicated as permanent that enables the user to save the object right after it is created. The parent object is not specified in the object parameters. The object is created in the repository root, which moniker is sent in the tParent parameter of the operation. The response contains description and the created object moniker.

SOAP request:

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<CreateObject xmlns="http://www.fsight.ru/PP.SOM.Som">
<tParent xmlns="">
  <id>FNDKOLJACBNNFOAEDCEENEKPOGMMOOGEBLEIHFKEJOFOFMNJ!M!0</id>
  </tParent>
<tArg xmlns="">
<info>
  <name>NewForm</name>
  <id>NewForm</id>
  <permanent>true</permanent>
  <classId>1538</classId>
  </info>
  </tArg>
  </CreateObject>
  </s:Body>
  </s:Envelope>

SOAP response:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<CreateObjectResult xmlns="http://www.fsight.ru/PP.SOM.Som" xmlns:q1="http://www.fsight.ru/PP.SOM.Som" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<id xmlns="">
  <id>FNDKOLJACBNNFOAEDCEENEKPOGMMOOGEBLEIHFKEJOFOFMNJ!M!304999</id>
  </id>
<object xmlns="" ds="" isShortcut="0" isLink="0" ver="1" hf="0">
  <i>NEWFORM</i>
  <n>NewForm</n>
  <k>304999</k>
  <c>1538</c>
  <p>0</p>
  <h>0</h>
  <hasPrv>0</hasPrv>
  <ic>0</ic>
  <trackElementDependents>0</trackElementDependents>
<obId>
  <id>FNDKOLJACBNNFOAEDCEENEKPOGMMOOGEBLEIHFKEJOFOFMNJ!M!304999</id>
  </obId>
  </object>
  </CreateObjectResult>
  </soapenv:Body>
  </soapenv:Envelope>

JSON request:

{
"CreateObject" :
{
"tParent" :
{
"id" : "FNDKOLJACBNNFOAEDCEENEKPOGMMOOGEBLEIHFKEJOFOFMNJ!M!0"
},
"tArg" :
{
"info" :
{
"name" : "NewForm",
"id" : "NewForm",
"permanent" : "true",
"classId" : "1538"
}
}
}
}

JSON response:

{
"CreateObjectResult" :
{
"id" :
{
"id" : "FNDKOLJACBNNFOAEDCEENEKPOGMMOOGEBLEIHFKEJOFOFMNJ!M!304999"
},
"object" :
{
"@ds" : "",
"@isShortcut" : "0",
"@isLink" : "0",
"@ver" : "1",
"@hf" : "0",
"i" : "NEWFORM",
"n" : "NewForm",
"k" : "304999",
"c" : "1538",
"p" : "0",
"h" : "0",
"hasPrv" : "0",
"ic" : "0",
"trackElementDependents" : "0",
"obId" :
{
"id" : "FNDKOLJACBNNFOAEDCEENEKPOGMMOOGEBLEIHFKEJOFOFMNJ!M!304999"
}
}
}
}
public static CreateObjectResult CreateObject(MbId mb, string id, uint classId)
{
var somClient = new SomPortTypeClient(); //Proxy object for operation execution
//Operation execution parameters
var tCreateObj = new CreateObject()
{
tArg = new CreateObjectArg()
{
info = new ObjectCreateInfo()
{
classId = classId,
id = id,
name = id,
permanent = true
}
},
tParent = new OdId()
{
id = mb.id + "!0" //Parent - repository root folder
}
};
//Create object
var result = somClient.CreateObject(tCreateObj);
return result;
}

See also:

CreateObject: Operation