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

Source link

Leave a Reply

Your email address will not be published. Required fields are marked *