Tuesday, October 19, 2010

Getting the GUID or internal field names of items in SharePoint

Many times during developing a SharePoint solution, we need to get the GUID of a list item, content type or a field but SharePoint does not display these GUIDs in an obvious way. In this post, I will discuss two ways that you can use to get the GUID of these items to be used during development.
One way to get the GUID is simply to navigate to the list settings page, copy the url, it will look like this:
http://YourServerName.com/_layouts/listedit.aspx?List=%7BEEF4F8B7%2D27D4%2D4A81%2D9E51%2D6A588EEF8D94%7D

The string after the List= is the encoded GUID i.e.
%7BEEF4F8B7%2D27D4%2D4A81%2D9E51%2D6A588EEF8D94%7D is the encoded GUID. Now you need to decode the GUID using one of these online tools (There are many resources online for encoding and decoding URLs that can do the same trick as well)

http://urldecoderonline.com/ (The is the best tool because you can copy the entire URL and it will break the URL to its complements which provides you with the list item very easily)
the decoded URL will look like this:
http://YourServerName.com/_layouts/listedit.aspx?List={EEF4F8B7-27D4-4A81-9E51-6A588EEF8D94}
so the list GUID is {EEF4F8B7-27D4-4A81-9E51-6A588EEF8D94}
To get the ID of a content type, navigate to the content type in the site content type gallery copy the string after the ctype of the URL and decode it, again, using one of the above tools. For example,
http://YourServerName/_layouts/ManageContentType.aspx?ctype=0x0107&Source=http%3A%2F%2FYOURSERVERNAME%5Flayouts%2Fmngctype%2Easpx
Encoded Content Type ID  0x0107
Decoded   Content Type ID  258
You can also apply the same technique to get the internal names of fields by using the string after the Field=
http://YourServerName.com/_layouts/fldedit.aspx?field=WorkPhone&Source=%2F%5Flayouts%2Fmngfield%2Easpx%3FFilter%3DAll%2520Groups


No comments:

Post a Comment