Select to view content in your preferred language

Second degree relationships

141
4
Jump to solution
a week ago
XV__
by
Occasional Contributor

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.

var url =
    "?referenceContext=addRelatedFeature" +
    "&itemID=" + mapID +
    "&featureSourceURL=" + actionURL +
    "&featureID=" + featureID +
    "&foreignKeyField=GlobalID";

return url;
 
I also tried substituting foreignKeyField with relationshipID.
 
It works fine for first-degree relationships, but not for second degree.
If the actionURL points to the point feature the error says there's no relationship, and if it points to the first degree table it errors out with Unable to Add Related Item.
 
Thoughts anyone?  @ColinLawrence maybe?
0 Kudos
1 Solution

Accepted Solutions
XV__
by
Occasional Contributor

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.

View solution in original post

0 Kudos
4 Replies
ChrisDunn1
Esri Contributor

@XV__ 

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

0 Kudos
XV__
by
Occasional Contributor

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;

 

0 Kudos
ChrisDunn1
Esri Contributor

@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

0 Kudos
XV__
by
Occasional Contributor

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.

0 Kudos