Hi all,
as described in this blog, we can use the FeatureSetByAssociation function, for example, to get all the containments of the station boundary. However, there is a message that the syntax is invalid if there is a variable as input (not $feature). Does anyone has an idea how to fix it?
Thank you.
var boundaries = FeatureSetByName($datastore, 'StructureBoundary', ['globalid'], true) //get all structure boundaries with geometry
var intersect = Intersects(boundaries, $feature) //get all boundaries that intersect with created feature
var stationBoundary = First(intersect) //select first station boundary (the only one) in order to convert from featureSet to feature
var content = FeatureSetByAssociation(stationBoundary, 'content') //get all containments of stationBoundary -> ERROR Invalid expression. Feature expected.
var assembly = Filter(content, "className = 'ElectricAssembly'") //filter containments for electricAssemblies
return{ //returns nothing - edits to containment of class "ElectricAssembly" with globalid of assembly
"edit":[{
"className": "^UN_Association",
"adds": [{
"fromClass": "ElectricAssembly",
"fromGlobalId": "assembly.globalid",
"toClass": "ElectricJunction",
"toGlobalId": "$feature.globalId",
"associationType": "container"
}]
}]
}
Solved! Go to Solution.
I believe the code is correct, but the validation logic is not returning a feature. So you just need to add a check for if stationBoundary is null and that way the validator exits early.
Add this under var stationBoundary = First(.....
if (IsEmpty(stationBoundary)){
return;
}
I believe the code is correct, but the validation logic is not returning a feature. So you just need to add a check for if stationBoundary is null and that way the validator exits early.
Add this under var stationBoundary = First(.....
if (IsEmpty(stationBoundary)){
return;
}
I work on the same problem as @OlgaKoblet and yes: the code finally validates. However, if we try to execute the code and create a new feature, it says that the Association already exists which - as far as I am concerned - shouldn't be possible, as we make a new association with a feature that isn't even there at the moment. Any tips on how we could solve this?
Code:
var boundaries = FeatureSetByName($datastore, "StructureBoundary", ["globalid"], true);
if(isempty(boundaries)){
return {"errorMessage": "no boundaries found."};
};
var intersectBoundaries = Intersects(boundaries, $feature);
if(isempty(intersectBoundaries)){
return {"errorMessage": "no intersected boundaries found."};
};
var structureBoundary = First(intersectBoundaries);
if(isempty(structureBoundary)){
return {"errorMessage": "no structure boundary found."};
}
var contentOfBoundary = FeatureSetByAssociation(structureBoundary, "content");
if(isempty(contentOfBoundary)){
return {"errorMessage": "no content found."};
}
var assembly = First(contentOfBoundary)
if(isempty(assembly)){
return {"errorMessage": "no assembly found."};
}
return{
"edit":[{
"className": "^UN_Association",
"adds": [{
"fromClass": "ElectricAssembly",
"fromGlobalId": "assembly.globalid",
"toClass": "ElectricJunction",
"toGlobalId": "$feature.globalid",
"associationType": "containment"
}]
}]
}
Throws this Error:
Thanks and kind regards!
The error is likely because of a duplicate association in your UN. This sound very similar to Bug BUG-000147861. Can you find that feature with the global id? You may have to look at the association table. The UDMS toolset has a GP tool that will generate a view of your association table. Apply a def filter on this using the reported global IDs and see if there is indeed a duplicate association.
How do I generate the view of the association tables? Which tool in GP tool I have to use? And how?
Thanks and kind regards!
Still working on the online help, but this is the tool - https://esri.github.io/Utility-Data-Management-Support-Tools/docs/2.9/AddUNSystemTables.html