質問

How to Show or hide part of report for different users logged in?

役に立ちましたか?

解決

As long as the object you're trying to hide has a property called RenderVariable, you can wire it up to be invisible/visible for specified users.

  1. Create a new Query called Global
  2. Add a Data Item to Global and name it "Current User"
  3. Enter the following expression into Current User: #sq($account.defaultName)# This is a macro which retrieves the name of the current user.
  4. Add a second Data Item and name it "IsAuthorized"
  5. Enter the following expression into IsAuthorized: if ([Current User] = 'Michael Jackson') then (1) else (0)
  6. Now test your new query by running the View Tabular Data command. (Hover over the Query Explorer to expand your Query list. Right-click on the query you just created and select "View Tabular Data")
  7. You should see your name in the Current User column and a 0 (zero) in the IsAuthorized column. That's because your name is not "Michael Jackson." (unless of course your name actually is Michael Jackson!)
  8. Assuming everything is working as planned, now you can move on and make a variable...
  9. Drag a Boolean variable onto your existing list of variables
  10. Call your variable DisplayWhenUserIsAuthorized_v
  11. Enter the following as the expression: if ([Global].[IsAuthorized]) then (1) else (0)
  12. Now you can plug this variable into the RenderVariable property of your object and you should be able to test that it works... it should not appear for you (it will only appear for Michael Jackson)

他のヒント

This link:

http://www-01.ibm.com/support/docview.wss?uid=swg21343986

shows how you get the current user in Cognos. You use this macro syntax to retrieve it:

#sq($account.defaultName)#

Put that in a layout expression on your report and verify that it returns the login name.

The next step is you may be able to use this in a variable expression, which you can then use to in conditional formatting to hide or show report elements.

If you don't know what I'm talking about, refer to Report Studio manuals and look up macros, layout expression, variables, conditional formatting.

You need to save different versions of your report for different users. Each custom layout is its own report.

You can then assign permissions so that users only see the report that is applicable to them.

For example, if you have a Sales report, and the Marketing department wants to add an extra calculated column into the report, but no other departments want to see it. Save the sales report with a new name like 'Monthly Sales - Marketing'. Add the new column.

Now if you have not already, create a new role called 'Marketing' in Administration->Security. Assign marketing users to this role.

On the 'Monthly Sales - Marketing' report, if you only want marketing to see the report, then edit the properties of the report, go to permissions, and give the marketing group 'Read', 'Execute' and 'Traverse'. Remove other users from the read/execute permission, and now only marketing and administrators will see the special Marketing report.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top