Jessie, thanks for your post and reply, it helped us figure out the same problem. We created a Dojo Memory store from a JSON file to get the PopupInfo based on what we built in an AGO webmap:
if (layer.serviceInfo) {
for (var j = 0; j < layer.serviceInfo.layers.length; j++) {
//create popup using popupinfo object already existing in JSON file
var popupTemplateStore = new Memory({
idProperty: "ID",
data: json.parse(popupTemplate)
});
var TemplatefromJson = popupTemplateStore.get(layer.serviceInfo.layers.id);
var PopupTemplate = new esri.dijit.PopupTemplate({
title: TemplatefromJson.popupInfo.title,
fieldInfos: TemplatefromJson.popupInfo.fieldInfos,
showAttachments: TemplatefromJson.popupInfo.showAttachments,
description: TemplatefromJson.popupInfo.description,
mediaInfos: TemplatefromJson.popupInfo.mediaInfos
})
//create the feature layer and apply the popup template
var fL = new esri.layers.FeatureLayer(item.url + "/" + layer.serviceInfo.layers.id, {
mode: 2,
layerId: layer.serviceInfo.layers.id,
id: item.id + "_" + layer.serviceInfo.layers.id,
infoTemplate: PopupTemplate,
outFields: ["*"]
});
this.map.addLayer(fL);
}
};