Khaled,
I started out with a new feature layer created through AGOL. Added the 2nd layer and relationship as below. When I attempt to add a record to the related table, it seems to go through (no errors) but it is not shown anywhere. The table remains empty.
Also, when I tried to export this feature layer as a FGDB, it also seems to fail in some way. The export screen stays up as if it is frozen. A file is created but it seems corrupt as I can't open it.
I'm guessing I must be doing something wrong with the JSON. Suggestions?
For adding layer:
{
"layers" : [
{
"name" : "Inspections",
"type" : "Table",
"fields" : [
{
"name" : "reference",
"type" : "esriFieldTypeGUID",
"alias" : "reference",
"sqlType" : "sqlTypeOther",
"nullable" : false,
"editable" : false,
"length" : 38,
"visible" : true,
"domain" : null,
"defaultValue" : null
},
{
"name" : "Insp_date",
"type" : "esriFieldTypeDate",
"actualType" : "datetime2",
"alias" : "Insp_date",
"sqlType" : "sqlTypeTimestamp2",
"length" : 8,
"nullable" : true,
"editable" : true,
"visible" : true,
"domain" : null,
"defaultValue" : null
},
{
"name" : "notes",
"type" : "esriFieldTypeString",
"actualType" : "nvarchar",
"alias" : "notes",
"sqlType" : "sqlTypeNVarchar",
"length" : 256,
"nullable" : true,
"editable" : true,
"visible" : true,
"domain" : null,
"defaultValue" : null
},
{
"name" : "ObjectId",
"type" : "esriFieldTypeOID",
"actualType" : "int",
"alias" : "ObjectId",
"sqlType" : "sqlTypeInteger",
"nullable" : false,
"editable" : false,
"visible" : true,
"domain" : null,
"defaultValue" : null
}
]
}
]
}
for adding relationship:
{
"layers" : [
{
"id" : 0,
"relationships" : [
{
"id" : 1,
"name" : "Inspections",
"relatedTableId" : 1,
"cardinality" : "esriRelCardinalityOneToMany",
"role" : "esriRelRoleOrigin",
"keyField" : "GlobalID",
"composite" : false
}
]
},
{
"id" : 1,
"relationships" : [
{
"id" : 1,
"name" : "Inspections",
"relatedTableId" : 0,
"cardinality" : "esriRelCardinalityOneToMany",
"role" : "esriRelRoleDestination",
"keyField" : "reference",
"composite" : false
}
]
}
]
}
Suggestions?