adding an item with relationship

Hello ALL,

I have an itemType (itemTypeOne) with 2 properties (propertyOne and propertyTwo) and one relationship  that has 2 properties : 
relationPropertyOne (datasource =itemTypeTwo) and relationPropertyTwo (datasource =stringValue)

What i want to do is create an item of itemTypeOne with relationship.

below is the code that i have developped without success :

const string url = "url of the instance";
const string db = "db-name";
const string user = "userName";
const string password = "password";
var httpServerConnection = IomFactory.CreateHttpServerConnection(url, db, user, password);
var loginResult = httpServerConnection.Login();

if (loginResult.isError()) return loginResult;

var remoteInnovator = IomFactory.CreateInnovator(httpServerConnection);

var relatedItem = remoteInnovator.newItem("itemTypeOne","add");

relatedItem.setProperty("propertyOne ", "value1");
relatedItem.setProperty("propertyTwo", "value2");

Item getValue= remoteInnovator.newItem("itemTypeTwo","get");
Item valeur= getValue.getPropertyItem("relationPropertyOne");

var relationship = remoteInnovator.newItem("relationshipName", "add");
relationship.setProperty("relationPropertyOne ", "stringValue");
relationship.setPropertyItem("relationPropertyOne ",valeur);

return relatedItem.apply();

NOTE: i have attached the server method in a button in the Main  Window Toolbar, and it's working fine when i test adding an item without relationship.
below the error when i click in the buuton:

Any help please ?

Parents Reply Children
No Data