Get the current logged Power Pages user Contact ID via JavaScript and use it to create records assigned to the current user


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
michelcarlo
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.

Author: michelcarlo

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.

Share This Post On
Share via
Copy link
Powered by Social Snap