简体   繁体   中英

Alfresco : How to filter documents in workflow

I have a special need in Alfresco, I'm unfortunately new in using this product.

Actually My intention is to show, in the workflow, only documents whose the coordinator is the logged on user and which are not in active workflows.

Any idea please :)

I'm back with a solution even if I'm not sure if it's the best. Any way that solved my problem.

I modified the method ObjectRenderer_renderCellAdd of object-finder.js to check if the user is the document coordinator and if there is no other active workflow linked to the document.

Instead of :

elCell.innerHTML = '<a id="' + containerId + '" href="#" ' + style + '   class="add-item add-' + scope.eventGroup + '" title="' + scope.msg("form.control.object-picker.add-item") + '" tabindex="0"><span class="addIcon">&nbsp;</span></a>';

I put :

var showSelectLink = true;
if(oRecord.getData("type") == "cm:content"){
showSelectLink = false;
//Checking if the document is already in an other active worflow
var xmlHttp = new XMLHttpRequest();
var url = window.location.href;
var arr = url.split("/");
xmlHttp.open( "GET", (arr[0] + "//" + arr[2]).concat("/alfresco/s/api/node/").concat((oRecord.getData("nodeRef")).replace(":/","")).concat("/workflow-instances"), false );
xmlHttp.send( null );

if(json.data.length == 0){
//Checking if the logged on user is the document coordinator
    xmlHttp = new XMLHttpRequest();
    xmlHttp.open( "GET", (arr[0] + "//" + arr[2]).concat("/alfresco/s/slingshot/doclib/permissions/").concat((oRecord.getData("nodeRef")).replace(":/","")), false );
    xmlHttp.send( null );
    var json = JSON.parse(xmlHttp.responseText);
    var hasDirectPermission = false;
    //Direct permission
    if(json.direct.length != 0){
        var permission;
        for(var index = 0; index < json.direct.length; index++){
            permission = json.direct[index];
            if(permission.role == "Coordinator"){
                showSelectLink = true;
                hasDirectPermission = true;
                break;
            }
        }
    }
    //Inherited Permission
    if(!hasDirectPermission && json.inherited.length != 0){
        var permission;
        for(var index = 0; index < json.inherited.length; index++){
            permission = json.inherited[index];
            if(permission.role == "Coordinator"){
                showSelectLink = true;
                break;
            }
        }
    }
}
}

if(showSelectLink){
   elCell.innerHTML = '<a id="' + containerId + '" href="#" ' + style + ' class="add-item add-' + scope.eventGroup + '" title="' + scope.msg("form.control.object-picker.add-item") + '" tabindex="0"><span class="addIcon">&nbsp;</span></a>';
 }

Regards,

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM