We have discussed how to customize Role Center in AL last year. Has anyone tried adding OnAction trigger to the action in Role Center?
Yesterday I received a question, he wanted to add an action to Role Center that would jump to the customer’s home page when selected. But when adding OnAction trigger in VS Code, an error was displayed.
A page of type Role Center cannot have triggers.
There is actually a note in Microsoft Document of OnAction Trigger. (Although a little different)
The OnAction trigger is not used on Role Center pages. If you add AL code to the trigger, the Role Center page will compile, but the AL code will be ignored at runtime.
So what should we do if we really need to add some code to run on the action of Role Center page?
In this post, I will share a very simple way to do this.
1. Create a new Codeunit, and then add the code to OnRun Trigger.
2. Create an action on the Role Center page, and in the RunObject Property of the action, set the codeunit just created.
For example: extends “Business Manager Role Center”
Test video: When you select the action (Open Url), OnRun Trigger in the codeunit will be executed. This is similar to execute the OnAction Trigger in the action.
Hope this will help.
Thanks for reading.