I'm new to m-files and to this community. I tried searching here and googling for these examples but I couldn't find anything helpful.
I'm working with Javascript and I followed m-files api documentation, but I ran into problem because the object I'm creating has some required fields and it has 2 subobjects which also have some required fields, there isn't any example of how to add subobject when doing POST, in fact POST process isn't explained well at all and it's quite confusing for us who are new to that.
Here's the sample data that needs to be sent (and some comments and questions):
var data = JSON.stringify({
PropertyValues: [
{
// Object1 (Parent Object) Class
PropertyDef: 36, // class id
TypedValue: { DataType: 9, Lookup: { Item: 133 } } // data type is lookup, and item 133 should be id of the object that is created?
},
{
// SubObject1 Class
PropertyDef: 14, // class id
TypedValue: { DataType: 9, Lookup: { Item: 115 } } // data type is lookup, and item 115 should be id of the object that is created? To this subobject have to be added 2 required properties, I don't know how to do that?
},
{
// SubObject2 Class
PropertyDef: 14, // class id
TypedValue: { DataType: 9, Lookup: { Item: 115 } } // data type is lookup, and item 115 should be id of the object that is created? To this subobject have to be added 2 required properties, I don't know how to do that?
}],
Files: []
});
var createObject = function () {
// Post the object data.
$.ajax({
url: host + "objects/133",
type: "POST",
dataType: "json",
contentType: "application/json",
data: data,
success: processDocument
});
};
I need someone to explain exact hierarchy and structure of the data that is about to be send, currently it is giving me error message: "Wrong data type for property definition "Additional classes".", ErrorCode: "154".
Is that error because I'm not sending those 2 subobjects with it's required fields or it's some other reason?
Thank you very much for the help!