Frage

I am trying to create custom NewForm.aspx. This form should auto populate current user login name display name and email details in the form when user load the NewForm.aspx.

Note : Without using jQuery and CSOM.

What is the query string parameter to get the current user info.

Is there is any way to get with the help of XSLT or else?

Keine korrekte Lösung

Andere Tipps

You can use CSOM or SPServices to get the current user.

To use SPServices, you need to include the JQuery and the SPServices scripts.

var thisUsersValues = $().SPServices.SPGetCurrentUser({
    fieldNames: ["Title", "Email"],
    debug: false
});

If no code is important to you, you could have multiple "People and Group" columns that all default to the value of [Me]. Then you have one attribute per column that you want to show from that user. One shows Email, another shows Username, another shows Display Name. enter image description here

I got solution for my question from Getting the Current User in SharePoint XSLT

SharePoint offers a couple of ways by which we can obtain the current user for use in a XSLT web part like DataFormWebPart or XsltListViewWebPart. All involve first setting parameters through the ParameterBindings property:

<ParameterBindings>
<ParameterBinding Name="UserID" Location="CAMLVariable" DefaultValue="CurrentUserName"/>
<ParameterBinding Name="LogonUser_" Location="WPVariable(_LogonUser_)"/>
<ParameterBinding Name="LogonUser" Location="ServerVariable(LOGON_USER)"/>
<ParameterBinding Name="AuthUser" Location="ServerVariable(AUTH_USER)"/>
<ParameterBinding Name="RemoteUser" Location="ServerVariable(REMOTE_USER)"/>
</ParameterBindings>
<Xsl>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl asp" xmlns:asp="System.Web.UI.WebControls" xmlns:ddwrt2="urn:frontpage:internal" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime">
<xsl:output method="html" />
<xsl:param name="UserID"/>
<xsl:param name="LogonUser_"/>
<xsl:param name="LogonUser"/>
<xsl:param name="AuthUser"/>
<xsl:param name="RemoteUser"/>
<xsl:template match="/">
UserID: <xsl:value-of select="$UserID"/><br/>
ID: <xsl:value-of select="ddwrt:UserLookup($UserID, 'ID')" /><br/>
EMail: <xsl:value-of select="ddwrt:UserLookup($UserID, 'EMail')" /><br/>
Login: <xsl:value-of select="ddwrt:UserLookup($UserID, 'Login')" /><br/>
LogonUser_: <xsl:value-of select="$LogonUser_"/><br/>
AuthUser: <xsl:value-of select="$AuthUser"/><br/>
RemoteUser: <xsl:value-of select="$RemoteUser"/><br/>
</xsl:template>
</xsl:stylesheet>
</Xsl>

Here we see different kinds of parameters:

  • CAMLVariable: built in variables UserID and Today;
  • WPVariable: returns one of the predefined values for WPID (web part client id), WPQ (web part unique id in page), WPR (web part resources folder full URL), WPSRR (web part resources folder relative URL), LogonUser (server variable LOGON_USER), WebLocaleId (current site locale, as in CultureInfo.LCID);
  • ServerVariable: returns one of the HTTP or IIS server- defined variables.
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit sharepoint.stackexchange
scroll top