Differences
This shows you the differences between two versions of the page.
Last revisionBoth sides next revision | |||
72:custom_report_tipsandtricks_switch [2019/02/07 13:50] – created ext-bkkr | 72:custom_report_tipsandtricks_switch [2019/03/08 19:07] – ext-bkkr | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Switch Context to Viewing User ====== | ====== Switch Context to Viewing User ====== | ||
+ | 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) { | ||
+ | | ||
+ | | ||
+ | } | ||
+ | function projectparent(project) { | ||
+ | var myprojects = | ||
+ | | ||
+ | var Path = new Array(); | ||
+ | if (myprojects.length == 0) { | ||
+ | | ||
+ | | ||
+ | } | ||
+ | var Name = myprojects[0].getProperty(" | ||
+ | | ||
+ | while (!Name.match(/ | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | if (myprojects.length ==0) | ||
+ | | ||
+ | Name = myprojects[0].getProperty(" | ||
+ | } | ||
+ | | ||
+ | } | ||
+ | asCurrentUser.run( function () { | ||
+ | var roles = currentUser.getEntities(" | ||
+ | for each ( role in roles) { | ||
+ | | ||
+ | | ||
+ | var project = role.getEntities(" | ||
+ | [0].getEntities(" | ||
+ | | ||
+ | | ||
+ | } | ||
+ | if (roles.length == 0) { | ||
+ | | ||
+ | | ||
+ | | ||
+ | } | ||
+ | |||
+ | } | ||
+ | ) | ||
+ | </ | ||