Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Controlling access to command buttons in Canvas page

  1. #1
    Senior Member
    Join Date
    Jan 2014
    Posts
    351

    Controlling access to command buttons in Canvas page

    Hi

    I have a canvas page with many command buttons.

    May I know how can I use Lianja security to control user access to certain command buttons on my Canvas page?

    Your assistance is much appreciated

    Thanks & Best Regards

  2. #2
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    7,159
    Blog Entries
    22
    Hi Tek Hong,

    You can use the UI presentation rules to "hide" or "disable" command buttons based on the UI presentation rules for "Visible when" and "Enabled when". These only take effect when you switch into runtime App view.
    Principal developer of Lianja, Recital and other products

    Follow me on:

    Twitter: http://twitter.com/lianjaInc
    Facebook: http://www.facebook.com/LianjaInc
    LinkedIn: http://www.linkedin.com/in/barrymavin

  3. #3
    Lianja MVP
    Join Date
    Dec 2012
    Location
    Croatia, Zagreb
    Posts
    1,135
    Hi Tek

    In VisibleWhen you can use functions explained here:

    The roles are all in the system!sysroles table (thats what the "Users" workspace works on). You can do what you want with this table at runtime. Passwords use the built-in md5() function to encrypt them.

    The userName() function returns the name of the logged in user.

    The userEmail() function returns the email address for the logged in user.

    The userRoles("username") function returns a comma separated list of roles applicable for a given user.

    The userDomain("username") function returns the "domain/tenancy" for that user.

    UI states can be used to hide/show UI elements based on the "roles" that a certain user has. Changing the "state" of the UI can set filters on sections. You create states using the UI state editor and change states using either the Lianja system object Lianja.changeState("name_of_the_state") or an inline delegate $("changestate:name_of_the_state"). The UI states editor has the ability to set multiple attributes for a given state. Why is the UI state machine important? Answer, because you don't have to hard code filters or anything like that into the App and you can modify "states" in one place.


    Also, take a look here:

    http://www.lianja.com/documentation/...nd-permissions

  4. #4
    Senior Member
    Join Date
    Jan 2014
    Posts
    351
    Hi Josip

    Thanks for your response. I also have a need to hide certain command buttons in my custom sections
    May I know what property I must set to dynamically hide code based command buttons in my custom section?

    Your advice is much appreciated

    Thanks & Best Regards

  5. #5
    Lianja MVP
    Join Date
    Dec 2012
    Location
    Croatia, Zagreb
    Posts
    1,135
    Hi Tek,

    You can use other function but lets say role is the best choice. You need to add new user with a role. E.g. user "n1" in role "r1".

    Name:  _SP32-20141229-113528.jpg
Views: 92
Size:  13.9 KB

    Be aware that you have to deploy user table too when you prepare your final installation.

    Now add 2 commandbuttons, first one with attribute VisibleWhen using function. Or some other logic.

    Name:  _SP32-20141229-113451.jpg
Views: 182
Size:  23.2 KB

    Log out and log in as users with and without role r1, to see it in action.
    Only second commandbutton is shown if you are not logged as user who is in role r1.

    Name:  _SP32-20141229-113611.jpg
Views: 186
Size:  7.1 KB

  6. #6
    Senior Member
    Join Date
    Jan 2014
    Posts
    351
    Hi Josip

    In my case, my commandbutton is created using code in custom section

    May I know what property I should set using code as I do not have an attributes panel for commanbutton created in code?

    Your kind assistance is much appreciated

    Thanks & Best Regards

  7. #7
    Hi Tekhong,

    Try this.

    In the top of your custom section, public the variable you are going to use for the button - under where it says namespace.

    For example.


    /
    // Lianja custom section for page "page1" section "section2"
    //
    namespace gap
    public tekbutton1
    define class page1_section2 as section
    .......
    .......

    Then anywhere in the code, you can just use
    tekbutton1.hide


    Herb

  8. #8
    and of course to show it, you use tekbutton1.show.

    Herb

  9. #9
    Senior Member
    Join Date
    Jan 2014
    Posts
    351
    Hi Herb

    Is there a property of commandbutton that allow me to specify the visibility expression?

    I checked the documentation and find only a "Visible" property which must be a boolean

    Your advice is much appreciated

    Thanks & best Regards

  10. #10
    Tek,

    It is the same thing.

    tekbutton1.hide is the same thing as tekbutton1.visible = .f.

    tekbutton1.show is the same thing as tekbutton1.visible = .t.

    All of these will work.

    Herb

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Journey into the Cloud
Join us