If you are working with Power Pages Pro Code Development, you might need to access the current logged user Contact ID for various purposes, such as personalizing the content, saving data using the WebAPI and relating to the current user.
In this blog post, I will show you how to do it via JavaScript in two different ways.
Liquid to help
To get the current logged user Contact ID via liquid we can to use the Liquid syntax {{user.id}}.
This will return the GUID of the Contact record that is associated with the current Power Pages user. Liquid code as you might be aware needs to be used in a WebTemplate, Content Snippet or Web Page code. So you would need to render the ID in an HTML element and retrieve this value later via JavaScript.
You can use this syntax anywhere in your Power Pages HTML code, and it will be replaced with the actual value when the page is rendered.
For example, you can use it to create a hidden input field that stores the Contact ID in a page,…
Source link
More About This Author
![michelcarlo](https://i0.wp.com/365community.online/wp-content/uploads/2020/04/C6zQCIg6_400x400.jpg?resize=150%2C150&ssl=1)
-
SharePoint and Office 365 Consultant/Developer always trying to get the best from Microsoft stack (Microsoft 365/Azure/Power Platform and related stuff).
Living in Ireland since 2018, I had previously worked in Brazil as a consultant/developer for Office 365, SharePoint and related technologies for almost 10 years.
Array
Modern Workplace24 July 2024Power Pages Table Permissions: Configure permissions to see records from child Accounts
Modern Workplace15 July 2024Copy Dataverse contact phone numbers across different environments based on Contact e-mail address using Power Automate
Modern Workplace1 June 2024Get the current logged Power Pages user Contact ID via JavaScript and use it to create records assigned to the current user
Modern Workplace11 May 2024How to get the current Azure Devops iteration name for a project using Power Automate