I had a long search and until I found a working script to use the logged in user id. Finally I have found the following Javascript code, put it in XSL to be used in an XMl viewer web part:
<script language="javascript" defer="true">
<xsl:comment>
<!(CDATA(
ExecuteOrDelayUntilScriptLoaded(init,'sp.js');
var currentUser;
function init(){
this.clientContext = new SP.ClientContext.get_current();
this.oWeb = clientContext.get_web();
currentUser = this.oWeb.get_currentUser();
this.clientContext.load(currentUser);
this.clientContext.executeQueryAsync(Function.createDelegate(this,this.onQuerySucceeded), Function.createDelegate(this,this.onQueryFailed));
}
function onQuerySucceeded() {
}
function onQueryFailed(sender, args) {
alert('Request failed. nError: ' + args.get_message() + 'nStackTrace: ' + args.get_stackTrace());
}
))>
</xsl:comment>
</script>
I call the function like this:
<A class="bluelink" href = "javascript:void(0)" onclick="javascript:window.location='{$mailtolink}' + '%0D%0Auserid: ' + currentUser.get_loginName() + '%0D%0Aurl: ' + window.location; return false;">Request additional rights</A>
The mailtolink
variable represents a valid mailto:
link. The problem is, that in IE11 (also in IE8 compatibility mode), the mail body ends only with
userid: i:0
However in Chrome, I get all the details I need:
userid: i:0#.w|tdomaintestuser
url: https://myserver/testsite/default.aspx
I made the mail body shorter, to make sure it is not the lenght, but I got the same results.
Can someone give me a hint how to make the script work in IE?