Jump to content
  • 0

Navigation by User Role


PDSRQ
 Share

Question

I found this in the community forum: https://forums.caspio.com/topic/16540-navigation-menu-that-varies-by-user-or-user-role/#comment-44997

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>

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0

Updated Script to show below, but it does NOTHING.  For a while when I didn't put the script, but put it in a conditional app, the only things that showed up was the @with the app name for the conditional menu, but if I post the script below, it is blank.  Very odd.

<div id="navMenuConditional"></div>
<script>
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>

Link to comment
Share on other sites

  • 0

Hi @PDSRQ - What is your HTML Code or Navigation in the App parameter? If it has line breaks or tab/double spaces - it would not work. I suggest using HTML compression to remove those spaces.

- https://www.textfixer.com/html/compress-html-compression.php
- https://www.willpeavy.com/tools/minifier/

On 1/18/2021 at 9:54 AM, PDSRQ said:

I found this in the community forum: https://forums.caspio.com/topic/16540-navigation-menu-that-varies-by-user-or-user-role/#comment-44997

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>

Link to comment
Share on other sites

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.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...