Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Hot answers tagged

25

If you know the SPWeb but not the document library, you can use SPWeb.GetFile: SPFile file = web.GetFile(guid);


23

The main advantage is a small performance benefit. Internally SharePoint is always using the GUID so the other methods have to find the GUID and the do the lookup using the GUID. The second advantage is that the user can't change the GUID.


10

Simpliest case Consider you know that document is stored in standard "Shared Documents" library from the Team Site Template, you should use this code: var library = web.GetListFromUrl("http://site/Shared%20Documents/Forms/AllItems.aspx"); var file = library.Items[new Guid("137DA01F-9AFD-5d9d-80C7-02AF85C822A8")].File; // file.Url - site-relative url of the ...


9

Using Client Object Model will help in this case: var oList; function getListTitleById() { var clientContext = SP.ClientContext.get_current(); oList = clientContext.get_web().get_lists().getById(__ID of the list__); clientContext.load(oList,"Title"); clientContext.executeQueryAsync( Function.createDelegate(this, this....


9

You can use the below rest call as well.: Replace guid with your list guid. $.ajax({ url: _spPageContextInfo.siteAbsoluteUrl + "/_api/web/lists(guid 'b778bbec-dd69-4a6c-9437-c73972c36292')", method: "GET", headers: { "Accept": "application/json; odata=verbose" }, success: function (data) { console.log("List Title ...


8

You should try $libraries = $web.lists | Where-Object { $_.BaseType -Eq "DocumentLibrary" } $libraries | Format-Table title,id -AutoSize $lists = $web.lists | Where-Object { $_.BaseType -Eq "GenericList" } $lists | Format-Table title,id -AutoSize The key here, is the SPList.BaseType property. As decribed in the SPBaseType Enumeration, there are other ...


7

At least three options are available: Option 1 Retrieve File Url via projected File object: /_api/Web/Lists/getByTitle('<list title>')/items?$select=File/ServerRelativeUrl&$expand=File Option 2 Retrieve File Url via FileRef property: /_api/Web/Lists/getByTitle('<list title>')/items?$select=FieldValuesAsText/FileRef&$expand=...


6

Here is a script that gets the UniqueId of a list item: <script type="text/javascript"> $(document).ready(function() { ExecuteOrDelayUntilScriptLoaded( function() { var itemId = ....; // change to the real id var listTitle = .... // the list title var ctx = SP.ClientContext....


6

There's the SPList.GetItemByUniqueId function, but if you don't know which list to search you're out of luck. If you're using SharePoint 2010, look at the Document ID functionality (which attaches a unique ID to a list item and then uses Search to find the item). Depending upon your requirements, you might consider implementing "...


6

Run the Get-SPFeature Powershell against your 2007 environment and it'll kick out a list of all of your features resolving the GUIDs to the names. Powershell Commands to List SharePoint Features To James' point, it sounds like you missed a step or two in your upgrade planning. Make sure you're running Test-SPContentDatabase before you kick off the actual ...


6

You can get it using REST query. The code should be: $( document ).ready(function() { GetListGuid('Lib1'); }); function GetListGuid(listTitle){ try { //REST Query to get the List Title jQuery.ajax( { url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getbytitle('"+listTitle+"')?$select=Id", type: "GET", ...


5

Yes, you can specify it. Example: public static readonly Guid MyFieldId = new Guid("{CC1E421C-29BE-4373-81D0-55D5D64B2E3D}"); public static readonly string MyFieldDefXml = "<Field ID=\"{CC1E421C-29BE-4373-81D0-55D5D64B2E3D}\"" + " Name=\"MyFieldName\" StaticName=\"MyFieldName\"" + " Type=\"Text\" DisplayName=\"My Field Name\"" + " Group=\"My ...


5

Both Get-SPDatabase or Get-SPContentDatabase powershell cmdlets retrun database GUID (among other attributes), if called without parameters, try to use it.


5

SharePoint Template files (.stp) are not zip files. They are actually cabinet files - so the correct extension if you want to browse their content would be .cab, not .zip. Since you were able to rename the template file to .zip and extract its content, I assume you aren't using the default Windows archive manager but instead you are using some external tool -...


4

You can use following PowerShell command to know all your Web Application's GUIDs. Get-SPWebApplication | Select DisplayName, Id However, bear in mind that, the GUIDs for each item in ULS logs are unique (typically for one unit of operation - like one page request) and they do not correspond directly to GUIDs of web application, unless the log suggests so....


4

If you know the name of the feature, you can retrieve the feature's definition ID by iterating the SPFeatureDefinitionCollection. Guid yourGuid; foreach (SPFeatureDefinition featureDef in web.FeatureDefinitions) { if (featureDef.DisplayName == "YourTitle" && featureDef.Scope == SPFeatureScope.Web) // Check the scope just to be safe { ...


4

The name of the list is meaningless as there can be lists by the same name all over a site. You would need the Url to the list in order to be able to resolve it to a Guid. However, the mechanics of this vary wildly depending on what you mean by "programmatically". In PowerShell it would be something like this and the server object model would be similar. ...


4

Assuming it's a Document Library, you can use $expand to bring information from the File along with the query Should be something like this: /sites/mysite/_api/web/lists/getbytitle('Rotating%20Banner')/items?$select=Id,Title,File/ServerRelativeUrl&$expand=File


3

Yes the Guid of the default fields like Title, Author, Created etc. stays the same across machines. You can reference them with the SPBuiltInFieldId class. E.g.: SPBuiltInFieldId.Title will give you the Guid of the Title field.


3

To elaborate on the second advantage above, short of an item being deleted, you are guaranteed to receive the same object for the duration of your process. This makes it possible to do things like change any and all options with your list, and still be able to properly reference it, or more practically, you could update page links that go to a certain item, ...


3

SPListItem has 3 "Item" methods defined that take an identifier between brackets: item[string fieldName] item[int index] item[Guid fieldId] You seem to be trying to use item[Guid fieldId], but you are providing a string, not a Guid structure, so in effect you are calling item[string fieldName] and thus SharePoint expects a field name, not a field id. You ...


3

Unfortunately, it is not possible to assign your own GUID when you create a list.


3

It's is not possible. The only ways to do this are: ClientContext(String) - Initializes a new instance of the ClientContext class for the SharePoint site with the specified absolute URL. ClientContext(Uri) - Initializes a new instance of the ClientContext class for the site with the specified Uri object. Link to source But you can use Site.OpenWebById() ...


3

GUID The G in GUID stands for Globally The U in GUID stands for Unique The ID in GUID stands for Identifier https://en.wikipedia.org/wiki/Globally_unique_identifier And yes there is a once in a 30 octillion chance it is not unique What is an octillion ?? I don't know.. But it sounds huge, and maybe a good lock-out period (in milliseconds, we should ...


3

Microsoft guarantees you uniqueness inside a SharePoint-Database, not more and not less. Even considering it is a very small possibility to have duplicates, it is possible if you have multiple databases inside the same farm. https://msdn.microsoft.com/EN-US/library/microsoft.sharepoint.splistitem.uniqueid.aspx


3

Nice Solution added by @users1100 for SharePoint 2013. You can try JSOM also. It will work for both 2010 & 2013. var clientContext = new SP.ClientContext(); var oList = clientContext.get_web().get_lists().getByTitle('Name of List or Library'); clientContext.load(oList) clientContext.executeQueryAsync(function() { console.log(oList.get_id()) }, ...


3

We can also achieve this by using PnP JS library. This is open source javascript framework contains lot of utility and helper methods based on SharePoint REST API. <script type='text/javascript' src='https://raw.githubusercontent.com/SharePoint/PnP-JS-Core/master/dist/pnp.min.js'></script> Include pnp js file to your application and call the ...


2

One quick trick (which doesn't quite get you what you want, but will be helpful) is to add "?Contents=1" to the end of the URL for any page. This will show you the /_layouts/spcontnt.aspx page which displays all of the Web Parts which are on the page, including those which are closed. It's often the case that the issues are with closed Web Parts, and you can ...


2

Sadly, you can't. You probably make it work by using the title of the list to get its instance instead of its internal GUID.


2

I know I'm stating the obvious, but you'll want to use the title rather than the GUID if you are building a site template. So, no, the GUID is not always the best choice...


Only top voted, non community-wiki answers of a minimum length are eligible