Select to view content in your preferred language

Get the attributes of a RelationshipQuery result

434
1
Jump to solution
05-10-2017 09:34 AM
SaraEL_MALKI
Occasional Contributor II

that's my code :

incidentLayer.on("click", function(evt) {
graphicAttributes = evt.graphic.attributes;
var relatedQuery = new RelationshipQuery();
relatedQuery.outFields = ["nom","code","tel"];
relatedQuery.relationshipId = 14;
relatedQuery.objectIds = [graphicAttributes.objectid];
incidentLayer.queryRelatedFeatures(relatedQuery, function(relatedRecords) {
var fset = relatedRecords[graphicAttributes.objectid];
var count = (fset) ? fset.features.length : 0;
//THE COUNT GIVES ME "1"
// I HAVE TRIED 
//alert("fset.features.attributes.nom"+fset.features.attributes.nom);
//console.log("relatedRecords[graphicAttributes.nom]"+relatedRecords[graphicAttributes.NOM]);
//console.log("relatedRecords[graphicAttributes.code]"+relatedRecords[graphicAttributes.CODE]); 
console.log(relatedRecords[graphicAttributes.objectid].features.attributes["code"]);
//BUT IT DOES NOT WORK !!
});
});

I wanna get the attributes' Code' and 'Name' of the result 

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
SaraEL_MALKI
Occasional Contributor II

I have found the solution:

featureLayerT.queryRelatedFeatures(relatedQuery, function(relatedRecords) {
var fset = relatedRecords[graphicAttributes.objectid];
if (fset.features.length >= 1) {
var items = dojo.map(fset.features, function(feature) {
return "<br/><span style='color:#663399'>Nom du Contrôleur: </span>"+feature.attributes['nom']+"<br/><span style='color:#663399'>Code: </span>"+feature.attributes['code']+"<br/><span style='color:#663399'>N° de Téléphone: </span>"+feature.attributes['tel'];
});
}

View solution in original post

0 Kudos
1 Reply
SaraEL_MALKI
Occasional Contributor II

I have found the solution:

featureLayerT.queryRelatedFeatures(relatedQuery, function(relatedRecords) {
var fset = relatedRecords[graphicAttributes.objectid];
if (fset.features.length >= 1) {
var items = dojo.map(fset.features, function(feature) {
return "<br/><span style='color:#663399'>Nom du Contrôleur: </span>"+feature.attributes['nom']+"<br/><span style='color:#663399'>Code: </span>"+feature.attributes['code']+"<br/><span style='color:#663399'>N° de Téléphone: </span>"+feature.attributes['tel'];
});
}
0 Kudos