0

我使用服务从服务器端获取当前用户 AD 列表,

我在全局工具栏上创建了一个新操作,如果用户不属于相关广告,我会尝试隐藏该操作,

我正在使用 Action isVisible() 函数,但我不能让 isVisible() 等到服务答案返回,我做错了什么?


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;
}

           

},```
4

1 回答 1

0

该方法invokePluginService()是异步的,不会等待请求完成。您可以使用同步方法来代替这种方法invokePluginServiceSynchronous()。这将等待请求完成并直接返回响应:

    var response = Request.invokePluginServiceSynchronous("OpenEntryTemplatePlugin",
        "CheckIfCurrentUserHaveSpecificADgroupService",{} );
于 2020-09-17T05:10:18.847 回答