AnsweredAssumed Answered

Editing related records for a layer that has been added programatically

Question asked by JWDavies on May 9, 2018
Latest reply on May 14, 2018 by JWDavies

In our web application we add layers programatically (map.addLayer(table)) when a user with editing permissions logs in.

 

However when the layers are added using this method, the related records are not visible.

 

If those layers are loaded into the portal webmap by default however, the related records are visible and editable.

 

This leads me to believe that I am missing a process which occurs when the webmap is loaded but is absent when a layer is loaded using map.addLayer().

 

I have discovered that in jimu.js\LayerInfos\LayerInfos.js there is a function called _addTable() which I am now using within the function _addToFinalLayerInfos()...

 

if (newLayer.id === "myRelatedTableLayer") {
  if (newLayerInfo) {
   var newTableInfos = [];
   var newTalbeInfo = this._addTable(newLayerInfo.layerObject, this._finalTableInfos);
     if (newTalbeInfo) {
      newTableInfos.push(newTalbeInfo);
     }
   this._onTableChange(newTableInfos, 'added');
  }
}

 

Using this function now means that the related table / related record appears where it should be, but whenever you click on the record, the attributeinspector doesn't appear and there are no errors in the browser console to explain why.

 

The layerInfos and fieldInfos of the config_Edit.json file all seem correct.

 

I am comparing the two attributeInspector objects that are created in the showInspector() function of the Edit Widget, but I cannot find any major differences between that of the webmap layer and that of the programatically added layer.

 

Does anybody have any idea as to why the attribute inspector of a related record might fail to load when the layer is added programatically?

 

I am using webappbuilder v2.5

 

Any help is appreciated,

 

Joe

Outcomes