I'm looking for help with setting a default tab in a Freedom UI page.
I want the "Lead Info" tab (which is the first tab) to always be selected by default when opening a lead record. However, after I perform or complete an activity and return to the Lead page, it automatically opens the "Lead Activities" tab instead of the "Lead Info" tab.
Is there a way to set the page to always open the "Lead Info" tab, regardless of the last active tab or navigation history?
Like
You can set the active tab using something like this (where "Tabs" is the name of the tab control):
request.$context.Tabs_SelectedTabIndex_Profile = 0;
I've not tried setting that in the crt.HandleViewModelInitRequest, but it could work - although might need to wrap in a setTimeout just to break out of the message loop and let the page load first and for the saved user profile for selected tab is loaded first (I don't believe there is a way to prevent that). Try something like this:
{ request: "crt.HandleViewModelInitRequest", handler: async (request, next) => { setTimeout(() => { request.$context.Tabs_SelectedTabIndex_Profile = 0; }, 1000); return await next?.handle(request); } }
Might need to play with the timeout interval (the 1000), although it's not 100% it will work.
Ryan
Try using this code in the handler:
{
request: "crt.HandleViewModelInitRequest",
handler: async (request, next) =>{
request.$context.Tabs_SelectedTabIndex_Profile=0;
return next?.handle(request);
}
}