Hi there folks,
Lately i've been working on a project to manage data in our company, it's very simple. It's a web page that users can input some data, e add reports on that data from time to time.
For that, i've created a point feature and and a related table. In WebApp Builder, through Smart Forms, it's possible to add the points, and the related records, very simple. BUT, working with WAB, i can't take advantage on some very useful Arcade functions and page layout it's kinda frozen, soooooo, i went to New MapViewer/Experience Builder to try.
I became very excited when i saw that is possible to add related records with the form editor, until i find out that it just won't work! The relationship between points and reports it's done by the GlobalID field in the point feature, but when I try to create a related record, it won't populate the related field on the new record.
The funny thing is that when I tried to do the same thing on FieldMaps, it works like a charm.
This is not the first time that i find problems with the form on New MapViewer, and have to go back do Old MapViewer and WebApp Builder, and not taking advantage on some cool features on Experience Builder.
Is this expected? Seems New MapViewer Form works very differently from FieldMaps, what should i do?
EDIT
Problem solved. The issue was the way I've created the relationship classes.
The relationship was created through REST API's Add to definition, with the request:
{
"layers":[
{
"id":0,
"relationships":[
{
"id":1,
"name":"relationship_name",
"relatedTableId":1,
"cardinality":"esriRelCardinalityOneToMany",
"role":"esriRelRoleOrigin",
"keyField":"GlobalId", //Here was the issue
"composite":false
}
]
},
{
"id":1,
"relationships":[
{
"id":1,
"name":"relationship_name",
"relatedTableId":0,
"cardinality":"esriRelCardinalityOneToMany",
"role":"esriRelRoleDestination",
"keyField":"GlobalID_FROM_PARENT_LAYER",
"composite":false
}
]
}
]
}
The issue was, that the key field I've used on the parent layer was not indentical, the correct field name was "GlobalID", with the capital "D". It seems that this may not be a issue with other apps, such as WebAppBuilder. So, when creating new relationship classes through the REST API, be careful with that.
So, I've got the job done by adding this to definition of the layer:
{
"layers":[
{
"id":0,
"relationships":[
{
"id":1,
"name":"relationship_name",
"relatedTableId":1,
"cardinality":"esriRelCardinalityOneToMany",
"role":"esriRelRoleOrigin",
"keyField":"GlobalID", //Name fixed
"composite":false
}
]
},
{
"id":1,
"relationships":[
{
"id":2,
"name":"relationship_name",
"relatedTableId":0,
"cardinality":"esriRelCardinalityOneToMany",
"role":"esriRelRoleDestination",
"keyField":"GlobalID_FROM_PARENT_LAYER",
"composite":false
}
]
}
]
}
Big thanks to @CraigGillgrass, with the help to work that out.