CRM WEBUI Technical: How to disable Breadcrumb/History navigation?
SAP CRM WEB UI Framework version CRM7.0 and higher.
Also this article applies only if BSP Runtime framework profile is set with history mode either ‘Automatic Recording of All Navigation Steps’ or ‘Automatic Recording of Changes in Work Area’ for a WEB UI Business Role.
This article explains the process to disable breadcrumb (Back and Forward) navigation for a particular screen in CRM WEB UI through code.
There will be some situations where we would have to disable the breadcrumb navigation in WEB UI. Typical scenario would be when we display data inside an overview page consisting of value nodes or a ‘Create screen’ where user enters data which creates a CRM specific transaction data and navigates to overview page, in such case user should not go back to the create screen again.
Note: In this article ‘View’ refers to the Main window or Overview page.
Solution in Summary:
Create an event handler method for ‘END_OF_NAVIGATION’ event of class ‘CL_BASP_WD_VIEW_MANAGER’ in your view controller class.
Get the instance of history manager class from the view’s ‘VIEW_MANAGER’ attribute.
Once you have the instance of class ‘CL_BSP_WD_HIST_MANAGER_BASE’, inactivate the history logging by calling method ‘SET_INACTIVE’.
Activate the handler in 'DO_VIEW_INIT_ON_ACTIVATION' and deactivate it inside 'WD_DESTROY_CONTEXT'.
Detailed analysis/explanation of the solution:
Class ‘CL_BSP_WD_HIST_MANAGER_BASE’ handles the functionality of breadcrumb navigation. This class has an event handler ‘ON_HISTORY_TRIGGER’ for event ‘HISTORY_TRIGGER’ of class ‘CL_BSP_WD_VIEW_CONTROLLER’ (which is the super class of every view). In case if the run-time framework profile is configured with either ‘Full recording’ mode or ‘Recording during changes in Work area’ then even if we do not raise event ‘HISTORY_TRIGGER’ in our view, standard view controller class triggers this event to capture the history data inside ‘BIND_VIEW’ method. So we cannot stop the triggering of this history event.
But if we examine the code in the event handler method ‘ON_HISTORY_TRIGGER’ we can see there is a check to log the history or not.
The attribute ‘LOGGING_ACTIVE’ can be set to false by calling the ‘SET_INACTIVE’ method of history manager class ‘CL_BSP_WD_HIST_MANAGER_BASE’.
Now our solution is to disable the history by setting this flag to value ‘false’ from our view. To achieve this we have to get the instance of the history manager class. We can get the instance of this class through view manager attribute.
Now the question is at which point we should set the flag to inactive. For this we have to understand the process of ‘History’ functionality in standard code.
If we go through the methods in the history manager class, ‘LOGGIN_ACTIVE’ flag is getting set to TRUE in method ‘SET_ACTIVE’ and this method is getting called inside method ‘ON_END_OF_NAVIGATION’ which is an event handler method for event ‘END_OF_NAVIGATION’ of interface ‘IF_BSP_WD_VIEW_MANAGER’.
Throughout a WEB UI session there will be always only one instance for the history manager class. Even if we set the flag to false standard method will set it back to true. So, it is important to set the flag value to ‘false’ after the execution of the standard method ‘ON_END_OF_NAVIGATION’.
For this purpose we have to create an event handler method ‘ON_END_OF_NAVIGATION’ for event ‘END_OF_NAVIGATION’ of class ‘CL_BSP_WD_VIEW_MANAGER in our view. In this method we are going to set the flag to inactive with below code.
When event ‘END_OF_NAVIGATION’ triggers our event handler will be called after the standard event handler since standard event handler sets to active before the loading of our view/page.
Before discussing about the place to set our event handler method active, let’s write code to deactivate our handler inside ‘WD_DESTROY’ method with below line of code. This will make sure that our method will not be triggered for the ‘end of navigation’ event once we leave our view/page, this is very important step otherwise other pages breadcrumbs won’t store in history.
SET HANDLER on_end_of_navigation FOR ALL INSTANCES ACTIVATION ABAP_FALSE.
Now let’s discuss about the place to activate our handler method. Generally we activate handler methods in ‘DO_INIT_CONTEXT’ method or any other ‘INIT’ methods. But in this scenario we should not activate our handler method in these methods because of the reason that the view manager’s event ‘END_OF_NAVIGATION’ triggers right after the INIT methods. To understand this go to method ‘PROCESS_NAV_QUEUE’ in class ‘CL_BSP_WD_VIEW_MANAGER’. Inside this method you can see that the event ‘END_OF_NAVIGATION’ triggers at the end. Whenever we navigate to our page from some other page, our view gets instantiated with the process that happens before this event trigger.
So, if we set our handler to active inside ‘DO_INIT_CONTEXT’, the handler will trigger even before the display of our view and since the navigation process is triggered from some other view this may lead to unwanted issues.
Because of issues explained above we will activate our handler inside one of the methods which triggers during rendering of our view like ‘DO_VIEW_INIT_ON_ACTIVATION’ or ‘DO_PREPARE_OUTPUT’. Since the former method triggers only once when the view gets activated, write below line to activate the event handler inside ‘DO_VIEW_INIT_ON_ACTIVATION’ method.
SET HANDLER on_end_of_navigation FOR ALL INSTANCES ACTIVATION ABAP_TRUE.
After implementing the above process you can successfully stop breadcrumb navigation for a particular page.