How can I access the data returned by serviceXhr? I want to access the series array in the function that called getSeries function. But It seems the data is retrieved in the successCallback and I can't get the data outside of it?
getSeries:function archive_list__getSeries(archiveList) {
this.serviceXhr({
url: AlfConstants.PROXY_URI + "/rl/archive/archive-list-series?archiveList=" + archiveList,
method: "GET",
successCallback: function (response) {
var series = [];
if (response && response.result)
{
var seriesData = response.result;
seriesData.sort(this.naturalSort);
for (var i=0; i<seriesData.length; i++)
{
var row = {
name: "alfresco/lists/views/layouts/Row",
config: {
widgets: [
{
name: "alfresco/lists/views/layouts/Cell",
config: {
widgets: [
{
name: "alfresco/html/Label",
config: {
label: seriesData[i].title + " (" + seriesData[i].id + ")"
}
}
]
}
},
this.getSeriesAddAction(seriesData[i].nodeRef)
]
}
};
series.push(row);
}
}
},
callbackScope: this
});
},
Hi, You can access below way.
_MyarrayData: null, constructor: function abc__constructor(args) { this.alfSubscribe(this.setData, lang.hitch(this, this.onSetData)); }, getSeries:function archive_list__getSeries(archiveList) { this.serviceXhr({ url: AlfConstants.PROXY_URI + "/rl/archive/archive-list-series?archiveList=" + archiveList, method: "GET", successCallback: function (response) { var series = []; if (response && response.result) { } }, callbackScope: this }); this.alfPublish(this.setData, { myData: pass_data_here }); }, onSetData: function bbbbb(publishPayload) { if (publishPayload && publishPayload.myData) { this._MyarrayData = publishPayload.myData; } }
Here _MyarrayData is variable.
Publish topic from getSeries which is subscribe in constructor and it will call onSetData which is assigning your data to that variable.After that you can access that variable like this._MyarrayDatat.
Ask for and offer help to other Alfresco Content Services Users and members of the Alfresco team.
Related links:
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.