Refresh Mobile Menu after Role Change

In my Menu block I have a CheckRoles action that is fired in the OnInitialize event:

The CheckRoles JavaScript node runs the following code:

and assigns the local parameters in the web block:

By assigning these output parameters to the roles, I am able to use IsTenant and IsFormerTenant in an If widget to either display or not display certain menu links.

In one of the app screens I am able to change the role of the user, using the GrantRole and RevokeRole functions inside an action, but I would like to refresh the menu after the role has been granted so that the links appear or disappear as appropriate once a role has been changed.

What is the best way to either refresh the menu block, or re-call my OnInitialize action of CheckRoles?

Hi Russel,

If you want to run an action that's inside a block, take a look here.

Hope it helps

Hi Henrique,

Although the article you linked to was incredibly illuminating, I don't think it applied to my scenario. As the menu block is not an instance block on the web screen I am calling from, I was unable to give it the runtime ID it required, and thereby expose the actions required as a function.

However, by placing the CheckRoles action inside OnInitialize it turns out it was firing after every click anyway. What I needed to do was access the local $roles object at the same time as the GrantRole server action so that the JavaScript role stayed in sync, and it appears that this is now firing correctly. Thank you so much for your help though.


Not sure if I understood your first post though, since the menu was not an instance on the screen.

Either-way, glad you worked it out :)


Hi Russel,

blocks has OnParametersChange event handler. You can put a integer control variable as parameter of your block, and make the arrangements similar those you had in OnInitialize 

On parent screen , after grant or revoke roles , you increase the control variable. This will trigger the OnParametersChange event of block and your code will run.


Fabio Fantato