Data View / Data Form: Parameters You Don’t Know About


From my old blogging site DataFormWebPart.com, this post continues to garner good amounts of traffic. Like in a previous blog entry, I am lifting my old post to put on here in hopes of it getting more visibility and use.


There is a collection of variables called ServerVariables that can access all of the IIS server variables. There are a lot of useful ones, and you can use these variables in your data view / form web parts as parameters.


Here are the basic steps access the variables:


1. On the Common Data View Tasks pane on your data view web part, click Parameters…


image


2. Click New Parameter, name the parameter MyServerVar (or, whatever you like), and set the Parameter Source to be Server Variable.


image


3. In Server Variable Name, enter in any of the available server variables (listed below). For sake of example, I am going to use LOGON_USER.


image


4. That’s it! Now MyServerVar can be used as a parameter in the data view / form web part. Use it to filter, sort, etc.


Here is a list of Server Variables you can use:






















































































































































Variable Description
ALL_HTTP Returns all HTTP headers sent by the client. Always prefixed with HTTP_ and capitalized
ALL_RAW Returns all headers in raw form
APPL_MD_PATH Returns the meta base path for the application for the ISAPI DLL
APPL_PHYSICAL_PATH Returns the physical path corresponding to the meta base path
AUTH_PASSWORD Returns the value entered in the client’s authentication dialog
AUTH_TYPE The authentication method that the server uses to validate users
AUTH_USER Returns the raw authenticated user name
CERT_COOKIE Returns the unique ID for client certificate as a string
CERT_FLAGS bit0 is set to 1 if the client certificate is present and bit1 is set to 1 if the cCertification authority of the client certificate is not valid
CERT_ISSUER Returns the issuer field of the client certificate
CERT_KEYSIZE Returns the number of bits in Secure Sockets Layer connection key size
CERT_SECRETKEYSIZE Returns the number of bits in server certificate private key
CERT_SERIALNUMBER Returns the serial number field of the client certificate
CERT_SERVER_ISSUER Returns the issuer field of the server certificate
CERT_SERVER_SUBJECT Returns the subject field of the server certificate
CERT_SUBJECT Returns the subject field of the client certificate
CONTENT_LENGTH Returns the length of the content as sent by the client
CONTENT_TYPE Returns the data type of the content
GATEWAY_INTERFACE Returns the revision of the CGI specification used by the server
HTTP_<HeaderName> Returns the value stored in the header HeaderName
HTTP_ACCEPT Returns the value of the Accept header
HTTP_ACCEPT_LANGUAGE Returns a string describing the language to use for displaying content
HTTP_COOKIE Returns the cookie string included with the request
HTTP_REFERER Returns a string containing the URL of the page that referred the request to the current page using an <a> tag. If the page is redirected, HTTP_REFERER is empty
HTTP_USER_AGENT Returns a string describing the browser that sent the request
HTTPS Returns ON if the request came in through secure channel or OFF if the request came in through a non-secure channel
HTTPS_KEYSIZE Returns the number of bits in Secure Sockets Layer connection key size
HTTPS_SECRETKEYSIZE Returns the number of bits in server certificate private key
HTTPS_SERVER_ISSUER Returns the issuer field of the server certificate
HTTPS_SERVER_SUBJECT Returns the subject field of the server certificate
INSTANCE_ID The ID for the IIS instance in text format
INSTANCE_META_PATH The meta base path for the instance of IIS that responds to the request
LOCAL_ADDR Returns the server address on which the request came in
LOGON_USER Returns the Windows account that the user is logged into
PATH_INFO Returns extra path information as given by the client
PATH_TRANSLATED A translated version of PATH_INFO that takes the path and performs any necessary virtual-to-physical mapping
QUERY_STRING Returns the query information stored in the string following the question mark (?) in the HTTP request
REMOTE_ADDR Returns the IP address of the remote host making the request
REMOTE_HOST Returns the name of the host making the request
REMOTE_USER Returns an unmapped user-name string sent in by the user
REQUEST_METHOD Returns the method used to make the request
SCRIPT_NAME Returns a virtual path to the script being executed
SERVER_NAME Returns the server’s host name, DNS alias, or IP address as it would appear in self-referencing URLs
SERVER_PORT Returns the port number to which the request was sent
SERVER_PORT_SECURE Returns a string that contains 0 or 1. If the request is being handled on the secure port, it will be 1. Otherwise, it will be 0
SERVER_PROTOCOL Returns the name and revision of the request information protocol
SERVER_SOFTWARE Returns the name and version of the server software that answers the request and runs the gateway
URL Returns the base portion of the URL

Source or read more about it on MSDN.


Note: A fun trick to see what the server variable values actually are is to output them into your data view: <xsl:value-of select=”$MyServerParam” />


Now whenever you change Server Variable Name (ex: LOGON_USER to AUTH_TYPE) the value will be reflected in your data view.


Comments (17)

  1. Hier habe ich ein paar Tipps zum SharePoint Designer zusammengestellt: Use SharePoint Designer to Email

  2. Hier habe ich ein paar Tipps zum SharePoint Designer zusammengestellt: Use SharePoint Designer to Email

  3. Hier habe ich ein paar Tipps zum SharePoint Designer zusammengestellt: Use SharePoint Designer to Email

  4. Direkter Download: SPPD-102-2008-08-14 Aktuell Feedback Usergruppen ISPA International SharePoint Professionals

  5. Direkter Download: SPPD-102-2008-08-14 Aktuell Feedback Usergruppen ISPA International SharePoint Professionals

  6. This came in perfect time. Just what I needed and exactly when I needed it. 🙂

  7. Dean says:

    Please get this info added to the SPD Help File. Having to search the internet for this type of information is a lot of extra work for users that could be prevented by adding a link in the Help file to this blog posting or section of the IIS help file.

    Thanks

  8. Pete P says:

    Hello Team Blog,

    WARNING – Long Post

    I need some help on how to add a hidden form field to the dataform part.  The field I need to add as a hidden field is from querystring.  

    Basically I have 1 page which consists of a drop down menu (section list).  When an item is selected from the drop down a related dataview is displayed (category list).  The hyperlink fields in the dataview have the section and category appended to the querystring.

    When the user selects one of the hyperlinks they are directed to the dataform page.  I know how to autopopulate the forms from querystring using javascript but I don’t want the user to change the values for these fields here.  I want to just display the values.  

    This appears to be a simple matter of changing the ControlMode on the formfield from New to Display – but when I do this it errors with :  failed to render column because of an error in the "single line of text field type control" – Value does not fall within the expected range.  FINE…

    I have also tried to set the visible property to false, but when I do that the field value does not get posted with the form.  

    So I have resorted to simply displaying the querystring using  <xsl:value-of select="$Category"/>.  This works great but I need a way to post the querystring with the form.

    How can I do this… …

  9. rmicone1 says:

    one more thing about querystrings… in order to send more than 1 variable from the XSLT data view, i had to use the html special var  "&amp;" instead of "%26"

  10. IAAF says:

    I have multiple subsites in my site collection.  Each subsite is for a different group but all share the same lists.  To prevent one office from seeing another office’s information I want to filter by sitename.  Is this possible?  

  11. chester says:

    How can I get the user’s email address?

  12. supradeepsripada says:

    hi, i am facing filtering/sorting issue. it is throwing javacript error. please help me

  13. cds1999 says:

    Once I have the server variable how do I go about passing that value.  For example I would like to send the value of the variable to a web service to perform a database query based on the value.

  14. Hari says:

    Hi

    How do i set the dataview parameter to a column in the lst?

  15. kom2000 says:

    Hi

    I am having a dropdown box on the dataform webpart and it is filtering depending on site column. The content is coming from a custom list and  by changing the value of the dropdown. But I want the content to be loaded for the particular item when the page layout loads. Now it is coming all listitems when the page loads. I checked weather OnLoad method exist for the webpart but I couldnt see nowhere.

    Can anyone help me to solvethis

  16. good post to know how we can use server variables