Each dataset script is executed by default with the datasource user. That means that the report is fixed to one user regardless of the user who is executing the report in Stages. With the asCurrentUser.run() method, it is possible to switch the context to the viewing user (the user who is executing the report in Stages).
function debug(str) { dataset.setColumnValue("debug",str); dataset.storeResultRow(); } function projectparent(project) { var myprojects = project.getEntities("hierarchy::hierarchic@LOCAL,targetrole=parent"); var Path = new Array(); if (myprojects.length == 0) { Path.unshift(project.getProperty("Name")); return Path; } var Name = myprojects[0].getProperty("Name"); Path.unshift(project.getProperty("Name")); while (!Name.match(/INDEX/)) { Path.unshift(Name); project = myprojects[0]; myprojects = project.getEntities("hierarchy::hierarchic@LOCAL,targetrole=parent"); if (myprojects.length ==0) break; Name = myprojects[0].getProperty("Name"); } return Path; } asCurrentUser.run( function () { var roles = currentUser.getEntities("containsUser@SYSTEM"); for each ( role in roles) { dataset.setColumnValue("user",currentUser.getProperty("Fullname")); dataset.setColumnValue("role",role.getProperty("DisplayName")); var project = role.getEntities("containsRole@SYSTEM") [0].getEntities("containsProcess@SYSTEM")[0]; dataset.setColumnValue("project",projectparent(project).join(">")); dataset.storeResultRow(); } if (roles.length == 0) { dataset.setColumnValue("user",currentUser.getProperty("Fullname")); dataset.setColumnValue("role","none"); dataset.storeResultRow(); } } )