14

How about a simple query: /_api/web/lists/getbytitle('<list title>')/items(<item id>) which will return all the field values for a list item with some limitation for User/Lookup fields: only lookup id values will be retrieved. In order to request all the field values including User/Lookup field values, you could specify * to select all the ...


13

Here is a basic example of how to get the selected items with javascript: var items = SP.ListOperation.Selection.getSelectedItems(); var myItems = ''; var i; myItems = items.map(function (v) { return '|' + v.id; }).join(''); Complete code for opening a modal page passing in list id and selected items: function resultCallback(result, value) { SP....


10

I solved this by using a CamlQuery directly after creation to return folders with the same name as a ListItemCollection: SP.CamlQuery query = new SP.CamlQuery(); query.ViewXml = "<View Scope='RecursiveAll'>" + "<Query>" + "<Where>" + "<And>" + "<Eq&...


10

@Ashish Patel answer does not actually work when i tried but i was able to figure it out a bit differently. Here is my version of the helper method based on example provided by code ninja blog, here: private List<Guid> GetTermsIds(SPListItem listItem, string fieldName) { var taxonomyField = listItem.Fields.GetFieldByInternalName(fieldName) as ...


9

AllowUnsafeUpdates=true; is not required to add/delete/update list items unless you are doing these operations in Page_Load or other Get methods. Both CASE 1 and CASE 2 does not look good in terms of best practice. Problems with both case code: Do not use oSPWeb.Lists["MyList"]; instead use oSPWeb.Lists.TryGetList("MyList1"); Do not use list.Items.Add(); ...


9

You could use the rest API below as mentioned. /_api/web/lists/getbytitle('<list title>')/ItemCount You will get item count of any list or library you have one more option to retrieve both You could construct the following query to return items and items count: /_api/Web/Lists/getByTitle('<list title>')?$select=ItemCount,Items&$expand=...


8

_spPageContextInfo Object could be used for retrieving information about current page on the client side, specifically pageListId property returns the current List Id. List Item Id could be extracted from a query string in Display/Edit pages, SharePoint client API GetUrlKeyValue function is used that purpose in the below example. The example demonstrates ...


8

Try to use this endpoint GetFolderByServerRelativeUrl to return all files and folder at a specific folder URL https://server/_api/Web/GetFolderByServerRelativeUrl(<folder url>)?$expand=Folders,Files To return only all files at a specific folder URL https://server/_api/Web/GetFolderByServerRelativeUrl(<folder url>)?$expand=Files For more ...


7

Refer following steps to set Retention / Information management policy : Goto list settings click on Information management policy settings click on Item content type tick on Enable retention check box click on Add retention stage fill out the Action and the Event Click OK Done Remember this retention policy will not run immediately after you are done with ...


5

So let's go with your first request. You want a piece of code to run when a list item is deleted from a list but it has to be 100% javascript and there can't be any page postbacks. Obviously we must assume the page is going to stay open the entire time. You are left with using web services or CSOM to achieve this. My recommendation would be to use ...


5

You could perform this via CSOM/REST API. Use SP.Web.getFileByServerRelativeUrl Method to request File object and specify SP.File.listItemAllFields property to load list item field values for the list item corresponding to the file: var ctx = SP.ClientContext.get_current(); var file = ctx.get_web().getFileByServerRelativeUrl(url); //get file ...


5

You can add OOTB SharePoint rating to a list. Go to the list > list settings > rating settings. Set "Allow items in this list to be rated?" to Yes and choose between having "Likes" or "Star ratings". Enable users to rate content


5

Most probably the error File not found occurs since you are trying to retrieve attachments folder that not yet exist in method HasListItemAttachment The following example demonstrates how to upload attachment file via SharePoint JSOM: function processUpload(fileInput, listTitle, itemId,success,error) { var reader = new FileReader(); reader.onload = ...


5

Note: Since june 2017 this answer no longer applies for SharePoint versions; Microsoft disabled the use of JavaScript in a Calculated Columns For long explanation and work arounds see: June 13th 2017 Microsoft blocked handling HTML markup in SharePoint calculated fields - how to get the same functionality back Original answer: Disclaimer: The best ...


5

The REST API does not have complete support for folders - particularly when it comes to working with list items. While it's quite possible that there is a way to get this to work using the REST API, you're much better off using the Client Object Model in this case. See: SP2013 : Create a list item inside a folder August 2020 Update: In the three years since ...


5

As per the documentation by Microsoft, you cannot select more than 100 items for bulk operations. The documentation says that: Where Boundary means you cannot configure the value. Its hard coded.


4

SPExportObject/SPImportObject can be used to migrate the list item, but only issue that you need to take care is if you export an item from a database (e.g. a list) without exporting it's parent, then the exported item will become orphaned in the package. A package can contain multiple different orphaned objects (e.g. if you export multiple different lists ...


4

Try something like: string siteUrl = "http://MyServer/sites/MySiteCollection"; ClientContext clientContext = new ClientContext(siteUrl); SP.List oList = clientContext.Web.Lists.GetByTitle("Announcements"); clientContext.Load(oList); clientContext.ExecuteQuery() ListItem oListItem = oList.GetItemById(2); clientContext.Load(oListItem); clientContext....


4

As long as the source and target lists are in the same site collection, you can move them with Manage Content and Structure (_layouts/sitemanager.aspx.


4

James your answer got me to look at it differently. If you want to create pages with the rest service I recommend you do the following. Create a page in the SharePoint site. Then download the page from the SharePoint server. This is the XML in the aspx page that needs to be uploaded to the server using the rest. (http://<yourSite>/pubsite/_api/Web/...


4

You should check more carefully what you are doing in the code. For example in the line TaxonomyField taxField = (TaxonomyField)item["Dept"]; you are trying to cast TaxonomyFieldValue object to TaxonomyField, which is incorrect, so you get ArgumentNullException on the next line because taxField becomes null. And you are resetting item field value for each ...


4

Check out this MSDN article which might help you out. Here's Microsoft's example code for adding a single item to a list (title field only): //Execute a REST request to get the form digest. All POST requests that change the state of resources on the host //Web require the form digest in the request header. HttpWebRequest contextinfoRequest = (...


4

Change NULL to null. I tried the following - first test resulted in a 400 Bad Request error, the second one worked fine. {'__metadata': { 'type': 'SP.Data.TasksListItem' },'StartDate': NULL} {'__metadata': { 'type': 'SP.Data.TasksListItem' },'StartDate': null}


4

You can make use of JavaScript Date Object for that. For example, while reading the data var scheduledTime = new Date(oListItem["ScheduledTime"]); Now you can calculate the new Time as follows var today = new Date(); var newScheduledTime = new Date(today.getYear(), today.getMonth(), today.getDate(), scheduledTime.getHours(), scheduledTime.getMinutes(), ...


4

Example: how to move list item into a folder via SharePoint JSOM API /** * Move ListItem * @param {SP.ListItem} list item * @param {string} targetFolderUrl - server relative url of folder where listitem needs to be moved */ function moveListItem(listItem,targetFolderUrl,success,error){ var ctx = listItem.get_context(); ctx.load(listItem,['...


4

MS Flow doesnt seem to allow you accomplish this at the moment - I came across this scenario as well. You may be able to do it if you set up your flow using the Logic Apps in Azure https://azure.microsoft.com/en-us/services/logic-apps/ You will need an azure subscription to create an app


4

An easy way for this is to create Parent items as Folder instead of item. You can create a custom Parent content type inheriting from Folder content type. Inside that Parent items , you can add your sub-items.


4

It is better to use: "/_api/web/lists/getbytitle('<list title>')/ItemCount" instead of: "/_api/Web/Lists/GetByTitle('<list title>')/Items" because "/ItemCount" is faster with quick response.


3

This is why you shouldn't use Folders in SharePoint, change your folder structure to a MetaData tree and you won't have this issue.


3

Try this: Console.WriteLine(listItem["Title"]); If you want to work with the DisplayName, you should do it like this: ctx.Load(listItemCollection, items => items.IncludeWithDefaultProperties(item => item.DisplayName)); The following link should help you out: http://blogs.technet.com/b/speschka/archive/2009/11/01/using-the-sharepoint-2010-client-...


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