Pergunta

I am using SharePoint Server 2007 Enterprise with Windows Server 2008 Enterprise, and I am using publishing portal template. I heard for SharePoint list/list column, it has an internal name which could be used for programming (as identifier for list/list column), and also has a display name (which is showed for end user for list name or list column name).

How to find and set such internal name and display name for list/list column?

Foi útil?

Solução

The dumbed down answer (Anders and Jaap are smarter than I am) is this:

When you create a column on a list, both its DisplayName and StaticName are set to the same value. However, the StaticName contains converted values for some characters, most notably a space ' ' is converted to '_x0020_'. So if the DisplayName is 'Product Description', then the StaticName will be 'Product_x0020_Description'.

There's another little bugaboo: The StaticName is limited to 32 characters including the translations for special characters. Because of this, if you have more than one column with the same first 20 characters, SharePoint creates StaticNames as follows:

  • 'Product Desciption 1' ---> Product_x0020_Description_x0020_
  • 'Product Desciption 2' ---> Product_x0020_Description_x0020_0
  • 'Product Desciption 3' ---> Product_x0020_Description_x0020_1

etc.

Clearly this renumbering can get confusing, too, so a lot of folks will create their columns without spaces in the names (ProductDescription1) and then change the DisplayName.

The easiest trick to see what the StaticName is (to me), to go to List Settings, and then click on the column name in which you are interested. On the Change Column page, the URL will end in something like:

/_layouts/FldEdit.aspx?List=%7B37920121%2D19B2%2D4C77%2D92FF%2D8B3E07853114%7D&Field=Product%5Fx0020%5FDescription

The StaticName is the value for the Field parameter in the QueryString. However, there's more encoding to deal with: the underscores ('_') are converted to '%5f'. So Product%5Fx0020%5FDescription means Product_x0020_Description again.

Whenever you change the DisplayName, the StaticName stays, well, static. This often results in DisplayNames and StaticNames that have nothing to do with each other, so as you are prototyping, it's a good practice to delete columns and re-add them if you are changing their purpose and therefore their name.

Methinks this has turned into a blog post for me! (UPDATE 2009-12-14: I did indeed post an edited version of this to my blog, and the comments and discussion have been interesting.)

M.

Outras dicas

You can use SharePoint Manager to inspect properties of existing fields, including the InternalName

Actually there are three strings involved, as can be easily seen from object model examination (or use of SharePointExplorer).

  1. DisplayName/Title

  2. StaticName

  3. InternalName

The StaticName of the site column can be updated by changing it in the feature ("StaticName" attribute) and redeploying. Then if the feature receiver gets the SPSite.SPField and calls Update, that will update the StaticName of all list instances.

The InternalName of the site column can be updated by changing it in the feature ("Name" attribute) and redeploying.

However, the site column InternalName is not propagated to list instances via SPField.Update, and AFAICT, cannot be changed, updated, or fixed at all.

Perhaps it is possible by twiddling with the underlying rows in the database, but that is obviously unsupported.

aside from using Sharepoint Explorer (wich is probably the best option), and in case that you need only the column internal name, you could also use u2u caml query builder. Also, you can find the column internal name when you browse the list, on its configuration page, and select any of the available columns. You can see that the internal name it is passed as an argument in the query string, inside the 'Field' key.

If you mean list template ID's you can find them here: http://msdn.microsoft.com/en-us/library/dd586520(office.11).aspx

Also theres the FieldId and PropertyConstant classes:

FieldId defines constants that you should use to reference SharePoint fields. PropertyConstants is the same deal, but for UserProfile fields.

Theres also lots of enumerations that you should use instead of hardcoding strings or id's. You will need to go scouting the API for a complete list, but one such enum is the ListType enum

hth Anders Rask

if you like me seek internal name in odata format

answer is here

OData__x0031_394

like this.

for do that enough to type in address bar this url :

http://server-sharepoint-name/_api/lists('%7B5EF6FE58-BD05-4C1E-9A3D-2CD9E219EBDD%7D')/items

and instead %7B5EF6FE58-BD05-4C1E-9A3D-2CD9E219EBDD%7D should replace your list ID

in the body of your explorer appear column names:

<?xml version="1.0" encoding="utf-8"?>
<feed xml:base="http://srv-shp-name/_api/" xmlns="http://www.w3.org/2005/Atom" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns:georss="http://www.georss.org/georss" xmlns:gml="http://www.opengis.net/gml">
    <id>fa843c10-bec8-4cd0-a52b-f1f2144bee9b</id>
    <title />
    <updated>2016-09-16T14:04:54Z</updated>
    <entry m:etag="&quot;2&quot;">
        <id>Web/Lists(guid'5ef6fe58-bd05-4c1e-9a3d-2cd9e219ebdd')/Items(1)</id>
        <category term="SP.Data.SatheBarNameRiziSode4AmaliatEjraeiListItem" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
        <link rel="edit" href="Web/Lists(guid'5ef6fe58-bd05-4c1e-9a3d-2cd9e219ebdd')/Items(1)" />
        <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/FirstUniqueAncestorSecurableObject" type="application/atom+xml;type=entry" title="FirstUniqueAncestorSecurableObject" href="Web/Lists(guid'5ef6fe58-bd05-4c1e-9a3d-2cd9e219ebdd')/Items(1)/FirstUniqueAncestorSecurableObject" />
        <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/RoleAssignments" type="application/atom+xml;type=feed" title="RoleAssignments" href="Web/Lists(guid'5ef6fe58-bd05-4c1e-9a3d-2cd9e219ebdd')/Items(1)/RoleAssignments" />
        <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/AttachmentFiles" type="application/atom+xml;type=feed" title="AttachmentFiles" href="Web/Lists(guid'5ef6fe58-bd05-4c1e-9a3d-2cd9e219ebdd')/Items(1)/AttachmentFiles" />
        <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/ContentType" type="application/atom+xml;type=entry" title="ContentType" href="Web/Lists(guid'5ef6fe58-bd05-4c1e-9a3d-2cd9e219ebdd')/Items(1)/ContentType" />
        <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/FieldValuesAsHtml" type="application/atom+xml;type=entry" title="FieldValuesAsHtml" href="Web/Lists(guid'5ef6fe58-bd05-4c1e-9a3d-2cd9e219ebdd')/Items(1)/FieldValuesAsHtml" />
        <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/FieldValuesAsText" type="application/atom+xml;type=entry" title="FieldValuesAsText" href="Web/Lists(guid'5ef6fe58-bd05-4c1e-9a3d-2cd9e219ebdd')/Items(1)/FieldValuesAsText" />
        <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/FieldValuesForEdit" type="application/atom+xml;type=entry" title="FieldValuesForEdit" href="Web/Lists(guid'5ef6fe58-bd05-4c1e-9a3d-2cd9e219ebdd')/Items(1)/FieldValuesForEdit" />
        <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/File" type="application/atom+xml;type=entry" title="File" href="Web/Lists(guid'5ef6fe58-bd05-4c1e-9a3d-2cd9e219ebdd')/Items(1)/File" />
        <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Folder" type="application/atom+xml;type=entry" title="Folder" href="Web/Lists(guid'5ef6fe58-bd05-4c1e-9a3d-2cd9e219ebdd')/Items(1)/Folder" />
        <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/ParentList" type="application/atom+xml;type=entry" title="ParentList" href="Web/Lists(guid'5ef6fe58-bd05-4c1e-9a3d-2cd9e219ebdd')/Items(1)/ParentList" />
        <title />
        <updated>2016-09-16T14:04:54Z</updated>
        <author>
            <name />
        </author>
        <content type="application/xml">
            <m:properties>
                <d:FileSystemObjectType m:type="Edm.Int32">0</d:FileSystemObjectType>
                <d:Id m:type="Edm.Int32">1</d:Id>
                <d:ContentTypeId>0x0100470E097D26C9784F9F4375502DB04E4B</d:ContentTypeId>
                <d:Title>استان آذربایجان غربی</d:Title>
                <d:OData__x0031_393 m:type="Edm.Double">690</d:OData__x0031_393>
                <d:OData__x0031_394 m:type="Edm.Double">1874</d:OData__x0031_394>
                <d:OData__x0031_395 m:type="Edm.Double">20505</d:OData__x0031_395>
                <d:OData__x0031_396 m:type="Edm.Double">27011</d:OData__x0031_396>
                <d:OData__x0031_397 m:type="Edm.Double">7390</d:OData__x0031_397>
                <d:Total93toNow>57470.0000000000</d:Total93toNow>
                <d:ostanId m:type="Edm.Int32">9</d:ostanId>
                <d:ID m:type="Edm.Int32">1</d:ID>
                <d:Modified m:type="Edm.DateTime">2016-08-28T15:06:56Z</d:Modified>
                <d:Created m:type="Edm.DateTime">2016-08-19T08:27:36Z</d:Created>
                <d:AuthorId m:type="Edm.Int32">33</d:AuthorId>
                <d:EditorId m:type="Edm.Int32">33</d:EditorId>

xml tags like this

7390

OData__x0031_397

Better idea is Delete column and Recreate.Is the Best solution

If you have Terminal Server access to the SharePoint server, the easiest way for me is to use SharePoint Management Shell and run the following:

$w = get-spweb http://server/path_to_site
$l = $w.Lists['your_list_TITLE_here']
$l.Fields | sort Title | ft Title, InternalName

The 'Title' column lists the field display name, and the 'InternalName' column its internal name.

As an alternative to server-side PowerShell, you can use SharePoint REST API:

http://server/path_to_site/_api/web/lists/GetByTitle('your_list_TITLE_here')/Fields?$select=Title,InternalName&$orderby=Title

That returns the same information formatted as an OData response. You may use the browser but some REST client is better, like Advanced Rest Client for Chome.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a sharepoint.stackexchange
scroll top