Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
72:custom_report_tipsandtricks_switch [2019/02/07 13:50] – created ext-bkkr | 72:custom_report_tipsandtricks_switch [2024/02/15 00:00] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
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) { | ||
+ | | ||
+ | | ||
+ | | ||
+ | } | ||
+ | |||
+ | } | ||
+ | ) | ||
+ | </ | ||