Robert - That worked. I did need to add a callback, but now it works well. Thanks so much for your help!!
This was the calling function:
onTest: function () {
var self = this;
self._openPrintWidget(function() {
this.PrintWidget.testPrint();
});
},
This was the final _openPrintWidget function:
_openPrintWidget: function (callback) {
//Opens print widget and assigns it to global variable PrintWidget
var printWidget;
var widgetCfg;
if (this.wManager) {
var widgetCfg = this._getWidgetConfig('Print');
if(widgetCfg){
printWidget = this.wManager.getWidgetByLabel(widgetCfg.label);
if(printWidget){
this.wManager.openWidget(printWidget);
this.pManager.showPanel(printWidget);
this.PrintWidget = printWidget;
callback();
} else {
//alert("code2");
var widgetsConfig = this.appConfig.widgetPool.widgets;
var widgetId;
for(var i in widgetsConfig){
if(widgetsConfig.name == "Print"){
widgetId = widgetsConfig.id;
break;
}
}
var abc = WidgetManager.getInstance().getWidgetsByName("AnchorBarController")[0];
abc.setOpenedIds([widgetId]);
setTimeout(function(){
printWidget = WidgetManager.getInstance().getWidgetById(widgetId);
console.info("PrintWidget: " + printWidget);
this.PrintWidget = printWidget;
callback();
},3000);
}
}
}
},