I use service to get the current user AD list from serverside,
I create a new Action on the global tool bar and i am trying to hide the action if the user dose not belong to the relevant Ad,
I am using the Action isVisible() function, but i cant make the isVisible() wait until the service answer is return, what i am doing wrong?
define([ "dojo/_base/declare","dojo/_base/lang", "ecm/model/Request", "ecm/model/Action","ecm/widget/dialog/AddContentItemDialog"],
function(declare,lang,
Request,Action,AddContentItemDialog) {
return declare("OpenEntryTemplatePluginDojo.OpenMyEntryTemplateAction",[ Action ], {
isUserBelogToSpecificADgroup:null,
isVisible:function(repository,listType){
if(!this.isUserBelogToSpecificADgroup){
Request.invokePluginService("OpenEntryTemplatePlugin","CheckIfCurrentUserHaveSpecificADgroupService",{//to know if the user is belong to the relevant AD group
requestCompleteCallback : dojo.hitch(this, function(response) {
if(response.success) {return response.success;}
else {
this.isUserBelogToSpecificADgroup = false;
return this.isUserBelogToSpecificADgroup ;
}
})
});
}else{
return false;
}
},```
The method invokePluginService()
is asynchronous and will not wait for the request to finish. Instead of this method you can use the synchronous method invokePluginServiceSynchronous()
. This will wait for the request to finish and returns the response directly:
var response = Request.invokePluginServiceSynchronous("OpenEntryTemplatePlugin",
"CheckIfCurrentUserHaveSpecificADgroupService",{} );