Hitachi Vantara Pentaho Community Forums
Results 1 to 5 of 5

Thread: Dashboards.context.user, not working for me

  1. #1
    Join Date
    Sep 2017
    Posts
    5

    Default Dashboards.context.user, not working for me

    Hello, I'm trying to get the current logged user in order to filter my query in cde.

    What I have done, is to create a javascript snippet in Resources Layout with this code:

    $(document).ready(function() {
    var param_user=Dashboards.context.user;
    Dashboards.fireChange("param_user",param_user);
    });

    where param_user is a simple parameter.

    (I read this in another post from here)

    When I try to run the dashboard, it shows me a blank page, if I delete the snippet then everything works (but of course I cannot filter the query)

    I have proved other combinations from other threads, but I am not been able to make it work.


    I'm using Pentaho 7.1.

    Any help will be apreciate.

    Sorry for my bad english, and thanks for all.

  2. #2

    Default

    I suspect you broken the following chain:
    1) the query uses ${param_user} in WHERE clause
    2) the datasource the query is in, defines Name:"param_user" (without quotes) in "Parameters"
    3) the component (component panel) defines in "Parameters": Arg:"param_user", Value:"param_user"
    4) the same component (component panel) has 'param_user' checked in "Listeners"
    Hope this may help
    Luciano

  3. #3
    Join Date
    Sep 2017
    Posts
    5

    Default

    Thanks Luciano

    I tried as you said but still have the issue.

    What I'm doing:

    Create a parameter: param_user, with a default value
    Insert a text input component, and assign the parameter as parameter, and listener

    if I execute the dashboard then text input shows me the default value. That's ok.

    Now I create a code snipplet from Layout Panel with the following code:

    $(document).ready(function() {
    var param_user=Dashboards.context.user;
    Dashboards.fireChange("param_user",param_user);
    });

    When I run the dashboard, it is empty, that is, it does not show my text input field.

    Thanks for all.

  4. #4

    Default

    in pentaho 7, dashoards have by default RequireJS=ON; your code expects RequireJS=OFF; did you reset this flag (CDE page, Settings button)?

  5. #5
    Join Date
    Sep 2017
    Posts
    5

    Default

    I did not,
    I have reseted it and Now it is working.

    Thanks for all.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Privacy Policy | Legal Notices | Safe Harbor Privacy Policy

Copyright © 2005 - 2019 Hitachi Vantara Corporation. All Rights Reserved.