1

PopupTemplate

var popupTemplate = { 
  title: "<font color='#F18E00'> Ladestation",
  content:[{
    type: "text",
    text: 
      "<p><b>Adresse: </b> </br>" +
      "{Adresse} </p>" +
      "<p><b>Kosten/Zahlungsart: </b> </br>" +
      "{Aufladegebühr}</p>" +
      "<p><b>Öffnungszeit: </b></br>" +
      "{Öffnungszeit:OpenTime}</p> " +
      "<p><b>Anschlussmöglichkeiten:</b></br>" +
      "{Anschlussmöglichkeiten:findRecords} </br></p>"
  },
  {
    type: "media",
    mediaInfos:[{
    type: "image",
    value: {
    sourceURL: "{Bild_Pfad}"
    }
    }]
  }
  ]  
};

facilities.popupTemplate = popupTemplate;

Relationship Query

findRecords = function (value, key, data) {
  var featObjId = data.Name;
  var Anschluesse = findRelRecords (featObjId, data);
};                          

async function findRelRecords (featObjId) {
  var FoundAnschluss = "";
  var relQueryAnschluss = new RelationshipQuery();
  relQueryAnschluss.outFields = ["Anschluss"];

  relQueryAnschluss.relationshipId = 0; 
  relQueryAnschluss.objectIds = [featObjId];

  var queryTaskAnschluss = new QueryTask({
    url: XXXXXXXXXXXXXXXXXXXXXXXXXXXX
  });

  await queryTaskAnschluss.executeRelationshipQuery(relQueryAnschluss).then(function(results){
    if (results[featObjId]) {

      dojo.forEach(results[featObjId].features, function(feature) {
        FoundAnschluss = FoundAnschluss + feature.attributes.Anschluss + "<br>";    
      });
      //return FoundAnschluss; 
    }
    });
//return FoundAnschluss
}

It is pretty much working until here. The function OpenTime which i am referring to in the popupTemplate is working fine aswell. (I'm getting a popup template with every content i applied as you can see, just the "Anschlussmöglichkeiten" are giving me a headache.)

So i tried to look the problem up and got to the conclusion it might be the function in the function whats the problem.

I tried to apply async and await because (maybe?) the relationship query took too long and it always gives back a blank return. Which i tried to trace in the dev tools. But after the async solution i tried both returns and none made a differnce.

I don't know if i used the async and await in a wrong way, don't give back FoundAnschluss at the right moment, or that the problem is in the Popup Template. I don't get an error in the dev console which leaves me kinda lost.

I really tried my best to find the problem, apply a solution but as a "noobie" i'm really lost.

I'm also not a native so im sorry if there is a language barrier. I'll try to answer any questions.

(I censored the url.)

Rick
  • 4,030
  • 9
  • 24
  • 35

0 Answers0