Control data query permissions based on accounts

  • Last update:  2021-10-20
  • I. Overview 

    1) Problem description

    Parameter blank In the drop-down box select all documents, describes how to query all data when parameter blank. In some cases, you want only a few people to have this permission. For example, only administrators can query all data without selecting options, while others must select options before they can query. How should this be implemented?

    2) Implementation roadmap

    In the post-initialization event of the drop-down box, obtain the current login user, use JS to determine whether it is an administrator, and set whether the drop-down box can be empty according to the judgment result.

    Note: Mobile  is not supported.

    II. Example 

    1. Data preparation

    Create dataset ds1, SQL statement:SELECT * FROM Sales_Volume where 1=1 ${if(len(Region)==0,"","and Region='"+Region+"'")}

    1.jpg


    2. Report design

    1) Design table as shown below:

    2.jpg

    2) Add region widget and configure data dictionary in parameter panel, as shown below:

    3.jpg


    3. Setting post-initialization events

    1) Add a post-initialization event to the dropdown widget

    4.jpg

    2) Set the parameter named user and the value of the parameter is $fine_username

    5.jpg

    3) The JavaScript code is as follows:

    if (user == "admin") {
    this.options.allowBlank = true;
    } else {
    this.options.allowBlank = false;
    }

    4. Effect preview

    Save the report, click Pagination Preview, the effect is as shown below:

    gif.gif

    III. Download the template

    Attachment List


    Theme: Parameter
    • Helpful
    • Not helpful
    • Only read

    滑鼠選中內容,快速回饋問題

    滑鼠選中存在疑惑的內容,即可快速回饋問題,我們將會跟進處理。

    不再提示

    10s後關閉

    Get
    Help
    Online Support
    Professional technical support is provided to quickly help you solve problems.
    Online support is available from 9:00-12:00 and 13:30-17:30 on weekdays.
    Page Feedback
    You can provide suggestions and feedback for the current web page.
    Pre-Sales Consultation
    Business Consultation
    Business: international@fanruan.com
    Support: support@fanruan.com
    Page Feedback
    *Problem Type
    Cannot be empty
    Problem Description
    0/1000
    Cannot be empty

    Submitted successfully

    Network busy