Fetch current logged in user via angular component in a freddom UI page
Hello,
I have an angular component that I load to my creatio instance via clio, andI place it in a Freedom UI List page. I want to handle some business logic in that component dependent on the current logged in user. How can I get that with JS and Angular?
Thank you,
Firas
Like
Hello Firas,
Since you are working with Freedom UI, the recommended approach is to use crt handlers rather than the old Terrasoft.SysValue. The current logged-in user is available via the $context object in your request handler.
Here’s an example of how you can access the current user in your Angular component logic:
handlers: [ { request: "crt.HandleViewModelInitRequest", handler: async (request, next) => { await next?.handle(request); // Access the current user information from the context const currentUser = request.$context?.CurrentUser; if (currentUser) { request.$context.UserName = currentUser.displayName; } } } ];
You can then use UserName inside your component template or for any business logic you need.
This way, your component will always get the correct logged-in user directly in Freedom UI.