Configure Dynamic Home Pages
16 min
overview dynamic home pages are an advanced customisation that allows activate to present different home pages to users based on runtime conditions unlike the standard configuration, which displays a single home page for all users, this approach uses a script to determine which home page should be shown when the user signs in the script can evaluate information such as the user's roles, attributes, department, or other business specific criteria before returning the appropriate home page this feature is intended for advanced implementations where different user groups require tailored landing pages or experiences it requires familiarity with activate scripting and the activate resource hierarchy the examples in this document demonstrate role based home page selection, but the same approach can be extended to implement virtually any business logic that can be evaluated within an activate script how it works normally, the homepage1 parameter references a single web form, meaning every user is presented with the same home page dynamic home pages replace this direct reference with a script each time a user signs in, the script evaluates one or more conditions and returns the appropriate home page as an xmlvalue the overall process is create a separate home page resource for each audience replace the homepage1 parameter with a script add the logic that determines which home page should be displayed return a default home page if none of the configured conditions are met because the script returns an xmlvalue, activate treats the returned resource exactly as though it had been configured directly in the homepage1 parameter create the home page resources create a structure beneath //resources/configuration/web/home pages for example //resources/configuration/web/home pages ├── administrators │ └── homepage ├── service desk │ └── homepage ├── managers │ └── homepage └── default └── homepage each homepage resource should contain the web form that will be presented to that audience you can organise these resources however you prefer the important requirement is that the resource paths referenced in the script match the actual resource locations configure the homepage1 parameter navigate to //resources/configuration/web change the homepage1 parameter from a web form to a script, then replace its contents with using system; using innovation activate; class script scriptbase { public xmlvalue main() { if (currentuser roles contains("administrators")) return evaluator getobject("=//resources/configuration/web/home pages/administrators/homepage") as xmlvalue; // todo put your other logic for dynamic home pages here // fallback to the default home page if no other conditions match return evaluator getobject("=//resources/configuration/web/home pages/default/homepage") as xmlvalue; } } the script now becomes responsible for determining which home page should be displayed whenever a user signs in understanding the script the script executes every time the home page is requested it evaluates each condition in order until one returns true when a matching condition is found, the corresponding home page resource is returned in the example above, the first condition checks whether the current user belongs to the administrators role if (currentuser roles contains("administrators")) if the condition evaluates to true, the administrator home page is returned return evaluator getobject( "=//resources/configuration/web/home pages/administrators/homepage" ) as xmlvalue; if the condition evaluates to false, execution continues to the next condition if no conditions match, the script returns the default home page adding additional conditions additional home pages can be introduced by inserting more conditions before the default return statement for example using system; using innovation activate; class script scriptbase { public xmlvalue main() { if (currentuser roles contains("administrators")) return evaluator getobject("=//resources/configuration/web/home pages/administrators/homepage") as xmlvalue; if (currentuser roles contains("service desk")) return evaluator getobject("=//resources/configuration/web/home pages/service desk/homepage") as xmlvalue; if (currentuser roles contains("managers")) return evaluator getobject("=//resources/configuration/web/home pages/managers/homepage") as xmlvalue; return evaluator getobject("=//resources/configuration/web/home pages/default/homepage") as xmlvalue; } } conditions are evaluated from top to bottom the first matching condition determines which home page is displayed for this reason, place the most specific conditions before broader ones default home page always include a fallback home page at the end of the script return evaluator getobject( "=//resources/configuration/web/home pages/default/homepage" ) as xmlvalue; this ensures every user receives a valid home page, even if they do not satisfy any of the configured conditions without a fallback, the script may return null, preventing a home page from being displayed using other conditions role membership is only one possible condition because the logic is implemented as an activate script, you can evaluate any information available through the scripting api examples include user roles user attributes department business unit location group membership licence or feature assignments custom resource values any other business specific logic regardless of the conditions used, each successful branch must return an xmlvalue that references a valid home page resource best practices store each home page in its own resource beneath a common home pages folder use descriptive resource names that clearly identify the intended audience keep condition logic simple and easy to follow place more specific conditions before broader ones always include a default home page comment complex business logic so future administrators understand the decision process testing test each configured scenario to ensure the correct home page is displayed verify that users receive the correct home page for their role or condition users matching multiple conditions receive the first matching home page users who do not satisfy any conditions receive the default home page every resource path resolves correctly all configured home pages load successfully troubleshooting the default home page is always displayed check that the user belongs to the expected role the role name matches exactly the condition appears before the default return statement the condition evaluates to true the home page fails to load check that the resource path is correct the referenced resource exists the resource contains a valid web form the script returns an xmlvalue every possible execution path returns a value the wrong home page is displayed the script stops processing once it finds the first matching condition review the order of your conditions and move the most specific conditions to the beginning of the script example resource structure //resources └── configuration └── web ├── homepage1 (script) └── home pages ├── administrators │ └── homepage ├── service desk │ └── homepage ├── managers │ └── homepage └── default └── homepage with this configuration in place, the homepage1 script becomes the entry point for determining which home page should be presented to each user, allowing a single activate environment to deliver tailored experiences based on your organisation's business rules