Hi, I'm building a task enabled map with Integration links to add relatedfeatures using forms inside the same map. In this case I have a task enabled feature layer with related tables. One related table has a second-degree relationship that I am trying to add records to with no success.
Solved! Go to Solution.
Unfortunately, after too much time trying to find where the problem was, I ended up adding a direct relationship between the 2nd-degree child and the 1st-degree parent feature, and then I added a hidden calculated expression in the field maps form to populate the visit guid (intermediate table).
Thanks @ChrisDunn1 for your help.
What you are attempting should be possible, but I think you'd have to call featureSetByRelationshipName to get the first related table record, then pull the featureID from that to build your addRelatedFeature app link. And be sure to include the url of the first related table as your featureSourceURL.
Chris
Thanks @ChrisDunn1 , I am already doing that.
var mapID = "xxxxxxxxxxxxxxxxxxxxxxxxxx";
//this is the url for the first-degree table
var visitURL = "https://xxxxxxxxxxxxxxxxxxxxxxxx/FeatureServer/1007";
// Find open visit
var visits = FeatureSetByRelationshipName($feature,"SO_Visit");
var openVisit = null;
for (var visit in visits) {
if (!IsEmpty(visit.time_arrival) && IsEmpty(visit.time_leaving)) {
openVisit = visit;
break;
}
}
var featureID = Replace(Replace(openVisit.GlobalID, "{", ""),"}","");
var url =
"https://fieldmaps.arcgis.app/" +
"?referenceContext=addRelatedFeature" +
"&itemID=" + mapID +
"&featureSourceURL=" + visitURL +
"&featureID=" + featureID +
"&foreignKeyField=GlobalID";
return url;
@XV__ at first glance that looks like it should work, with a caveat.
Before I suggest some involved troubleshooting I would look at the foreignKeyField. Is GlobalID used in both relationships? It may be trying to traverse back to the parent instead of to the second related table. Is there an error in the troubleshooting log saying that the featureID isn't found?
Relationship-based app links were updated earlier this year to be more declarative as well - you can now specify a relationshipID parameter and use the primaryKeyField parameter to ensure you're traversing the exact relationship you want - there are more details and examples in this documentation.
I would look at the service definition json for the first related table and use the relationshipID and primaryKeyField that is associated with the second related table. You could also hard-code a test link and just launch it from an e-mail or similar in order to make sure this flow works before trying to dynamically build the links with arcade, just as an additional test.
As a side note, there's also a StandardizeGuid function now that you can use instead of manually replacing characters. I think "digits-hyphen" is the format you'd want for a feature ID in an app link.
I hope that helps!
Chris
Unfortunately, after too much time trying to find where the problem was, I ended up adding a direct relationship between the 2nd-degree child and the 1st-degree parent feature, and then I added a hidden calculated expression in the field maps form to populate the visit guid (intermediate table).
Thanks @ChrisDunn1 for your help.