At some point you may encounter the need to find out the logged-in users ID and pass dynamically pass it into a URL when clicked. This can be achieved by creating a Web Resource with the following code pasted into it:


<html>

<head>
	<meta charset="utf-8">
	<title>Example Code</title>
	<script type="text/javascript">
	function openExternalLink() {
		window.open("https://Exampleurl.com/example/" + parent.Xrm.Page.context.getUserId().slice(1, -1).toLowerCase(), "_blank");
	}
	</script>
	<meta>
</head>

<body onload="openExternalLink();" onfocusout="parent.setEmailRange();" style="overflow-wrap: break-word;"> </body>

</html>

Your content goes here. Edit or remove this text inline or in the module Content settings. You can also style every aspect of this content in the module Design settings and even apply custom CSS to this text in the module Advanced settings.

Daxtra Search

Make sure you replace the sample URL in the HTML code with your destination address and VIOLA, you should be able to dynamically query the user GUID and add it onto the end of the web address.