AnsweredAssumed Answered

We are trying to bring an attachments in our info-window (POPUP) on service points in our dashboard. I am able to get the attachments in info-window when I am trying to debug with breakpoints and forcefully give the meter number that has attachments then

Question asked by RDirisala_mlgw on Mar 23, 2017

We are trying to bring an attachments in our info-window (POPUP) on service points in our dashboard. I am able to get the attachments in info-window when I am trying to debug with breakpoints and forcefully give the meter number that has attachments then GetAttachments method's return but without debugging code return simple at Queryids method itself can any one please help us where is the problem actually . I also tired the classback also but it didn’t work either. Please let me know if you want to know more info we can setup an gotomeeting and look into this.

 

Here is the code

 

if (graphic._layer.name == "SDE.Service") {
            var imageInfos = GetAttachments(meternumber,attributes, serviceType);              
            if(imageInfos != null)
            {
               if(imageInfos.length > 0)
               {
                msg += imageInfos;    
                }
                else
                {
                  msg += "<b> This feature has no associated attachments. </b>";
                }
            }
             else
             {
                    msg += "<b> This feature has no associated attachments. </b>";
             }  
             
                 
            }
            return  msg;
          }

         function GetAttachments(meternumber,attributes, serviceType){  
          var nodes = null;  
          var meterUrl = smartMeterMapURL +"/" +serviceType+"/" +"?token=" + token;
          var featureLayer = new FeatureLayer (meterUrl);
          var query = new esri.tasks.Query();         
          query.where = "METERNUMBER = " + meternumber;
          featureLayer.queryIds(query, function(objectIds){nodes = ImageQuery(objectIds, serviceType);});          
          return nodes;
          }

          function ImageQuery(objectIDs, serviceType){  
          var imageTags = [];
          if(objectIDs != null)
          {    
          var objectID =   objectIDs[0];      
           var attachUrl = smartMeterMapURL + serviceType +"/" + objectID + "/attachments?f=json&token=" + token;
          var attachmentsArray = esriRequest({
                    url: attachUrl,
                         handleAs: "json"
                    });
                    attachmentsArray.then(
          function(response) {
          for(var i = 0; i< response.attachmentInfos.length; i++){
            var ImageNo = response.attachmentInfos[i].id;
            var imageTag = "<br /><a target='_blank' href=" + smartMeterMapURL + serviceType + "/"+ objectID + "/attachments/"+ ImageNo + "?token=" + token +  "> Attach Image: " + ImageNo +"</a>";
            imageTags.push(imageTag);
            }
           }, function(error) {
           console.log("Error: ", error.message);
            });
            return imageTags;
            }
            else
            {              
              return imageTags;
            }
          }

Outcomes