AccessNerd Posted October 28, 2020 Report Share Posted October 28, 2020 Hi All, Noob here. Is there any way to create a navigation menu using the app parameters method that can change by the user role? For example a standard user may have "Add New | Reporting" where as an admin may have "Add New | Reporting | Users | Advanced Tools" etc. I'm open to other ideas, but the app parameters is such an easy implementation. I'm a Caspio noob so any assistance is greatly appreciated. Thanks. Quote Link to comment Share on other sites More sharing options...
1 Barbie Posted October 29, 2020 Report Share Posted October 29, 2020 Hi @AccessNerd, You may want to check this article: https://howto.caspio.com/authentications-and-connections/authentication/record-level-security/restrict-access-to-data-by-user-or-role/ Also, you need to add multiple app parameters base on what you want to display. I hope this helps. - Barbie Quote Link to comment Share on other sites More sharing options...
1 CoopperBackpack Posted October 29, 2020 Report Share Posted October 29, 2020 Hello @AccessNerd, As Barbie mentioned above first of all you need to have a Role field in your Users table that is the data source for your Authentication. Then you need to create 2 different app parameters. Here is the tutorial video that can be helpful: Adding a Navigation Menu to Caspio DataPages https://www.youtube.com/watch?v=XCxGl1aUixk And the last step is to add the JavaScript code to the Header section of the DataPage. <div id='navMenuConditional'></div> <script type="text/javascript"> document.addEventListener('DataPageReady', function (event) { if ('[@authfield:role]' == 'Admin') { document.querySelector('#navMenuConditional').innerHTML = '[@app:Nav_menu_admin]' } else if ('[@authfield:role]' == 'Agent') { document.querySelector('#navMenuConditional').innerHTML = '[@app:Nav_menu_agent]' } }); </script> Please replace the field name ([@authfield:role]), roles names (Admin, Manager), app parameters names with your local names. Feel free to update this thread if you have any questions. Quote Link to comment Share on other sites More sharing options...
0 Barbie Posted October 29, 2020 Report Share Posted October 29, 2020 Hi @AccessNerd, In addition to what I mentioned above, you may consider using Rules as well which will check what is the role if the user who's logged in then you can configure which section you want to hide. But Rules is only applicable in Submission and Details DataPage. Please refer to this article: https://howto.caspio.com/datapages/forms/conditional-forms/ - Barbie Quote Link to comment Share on other sites More sharing options...
0 AccessNerd Posted October 30, 2020 Author Report Share Posted October 30, 2020 thanks to both of you, I'll give this a try. Quote Link to comment Share on other sites More sharing options...
0 AccessNerd Posted October 30, 2020 Author Report Share Posted October 30, 2020 On 10/29/2020 at 4:27 AM, CoopperBackpack said: Hello @AccessNerd, As Barbie mentioned above first of all you need to have a Role field in your Users table that is the data source for your Authentication. Then you need to create 2 different app parameters. Here is the tutorial video that can be helpful: Adding a Navigation Menu to Caspio DataPages https://www.youtube.com/watch?v=XCxGl1aUixk And the last step is to add the JavaScript code to the Header section of the DataPage. <div id='navMenuConditional'></div> <script type="text/javascript"> document.addEventListener('DataPageReady', function (event) { if ('[@authfield:role]' == 'Admin') { document.querySelector('#navMenuConditional').innerHTML = '[@app:Nav_menu_admin]' } else if ('[@authfield:role]' == 'Agent') { document.querySelector('#navMenuConditional').innerHTML = '[@app:Nav_menu_agent]' } }); </script> Please replace the field name ([@authfield:role]), roles names (Admin, Manager), app parameters names with your local names. Feel free to update this thread if you have any questions. The code above looks pretty spot on. I'll have to see if I can make that work. Thanks for that. CoopperBackpack 1 Quote Link to comment Share on other sites More sharing options...
0 PDSRQ Posted January 18, 2021 Report Share Posted January 18, 2021 I ammended it below, but it doesn't work. Does anyone have any ideas? The table name is Sarasota_Users_1 and the filed is Role. Different types of roles listed are : Finance, Cost Center, Admin. Thanks for any help you can provide as I am trying to add this to the header. (Also, does anyone know if you could take the script below and make it an App?) <div id='navMenuConditional'></div> <script type="text/javascript"> document.addEventListener('DataPageReady', function (event) { if ('[@authfield:Sarasota_Users_1_Role]' == 'Finance') { document.querySelector('#navMenuConditional').innerHTML = '[@app:FiscalNavigation2022]' } else if ('[@authfield:Sarasota_Users_1_Role]' == 'Cost Center') { document.querySelector('#navMenuConditional').innerHTML = '[@app:CostCenterNavigation2022]' } }); </script> Quote Link to comment Share on other sites More sharing options...
0 ParkLoey Posted December 15, 2021 Report Share Posted December 15, 2021 Hiyaa! Just wanted to add this thread I found. I think it's the same use case so you can use it as extra reference: Quote Link to comment Share on other sites More sharing options...
0 Kurumi Posted March 25, 2022 Report Share Posted March 25, 2022 Hi - sharing this new post! Quote Link to comment Share on other sites More sharing options...
0 Kurumi Posted September 30, 2022 Report Share Posted September 30, 2022 Hi @PDSRQ- you can check this recent post: Quote Link to comment Share on other sites More sharing options...
0 autonumber Posted January 12, 2023 Report Share Posted January 12, 2023 Hello! Just to update this post, I had a similar workflow where I have navigation menu on my app parameter and used the script provided here however, it didn't work. After several testing, I noticed that if your navigation menu on the app parameter has style on it or <style> tag, the .innerHTML wil not render the app parameter. You will need to remove the styles on the app parameter and instead place it on the header of the DataPage. Hope this helps! bookish 1 Quote Link to comment Share on other sites More sharing options...
0 bookish Posted April 16, 2023 Report Share Posted April 16, 2023 @autonumber thanks for this. I had a feeling the style was not working for me. I will try this. Quote Link to comment Share on other sites More sharing options...
0 PotatoMato Posted March 14 Report Share Posted March 14 Hi! Just to update, Caspio has an article about custom navigation menu based on user role: https://howto.caspio.com/tech-tips-and-articles/customizing-navigation-menu-based-on-user-roles/ -Potato Quote Link to comment Share on other sites More sharing options...
Question
AccessNerd
Hi All,
Noob here. Is there any way to create a navigation menu using the app parameters method that can change by the user role?
For example a standard user may have "Add New | Reporting" where as an admin may have "Add New | Reporting | Users | Advanced Tools" etc.
I'm open to other ideas, but the app parameters is such an easy implementation. I'm a Caspio noob so any assistance is greatly appreciated.
Thanks.
Link to comment
Share on other sites
12 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.