Tag Info

Hot answers tagged

10

You load multiple items. A conflict occurs. Collect all items you need and call "load". After you call load for all items, then run context.executeQueryAsync. Save your selected items as a global variable (this.items): function showTitles(urlColumnName) { var context = new SP.ClientContext.get_current(); var web = context.get_web(); var lists = ...


7

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>" + ...


6

Save the list as a template and recreate the list. ID columns will always keep incrementing and will never be reused.


6

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(); ...


5

@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 ...


5

This is how you do it TaxonomyFieldValueCollection tfvc = (list.Items[0]["Field Name"] as TaxonomyFieldValueCollection); var valuesList = (from v in tfvc select v.Label).ToList();


4

Navigate to corresponding Elements.xml, and you will notice Receivers element with ListTemplateId attribute, like this: <Receivers ListTemplateId="100"> ... </Receivers> What you need is to use ListUrl attribute instead, and point it to the specific list using provided url. There is a how-to on this on MSDN: ...


4

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 = ...


4

Well, SPSecurity.RunWithElevatedPrivileges should do the trick. Make sure, you create a new SPSite/SPWeb within the elevated code block: var siteId = SPContext.Current.Site.ID; SPSecurity.RunWithElevatedPrivileges(delegate() { using (SPSite site = new SPSite(siteId)) { //do things on the new site object } });


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 ...


4

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 ...


3

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); ...


3

If you are calling the ItemAdding event, the ListItemId is not going to exist yet. Try using the ItemAdded event instead.


3

I found a way. There is a class FieldUrlValue in the Client Ojbect Model for this type of situations. Here's how I implemented it: ListItemCreationInformation lici = new ListItemCreationInformation(); ListItem item = list.AddItem(lici); FieldUrlValue link = new FieldUrlValue(); link.Url = "http://some-address"; link.Description = "Some Address Title"; ...


3

I found solution which runs perfectly in my case: Use LockedByUser property of SPUser class. The code item.File.LockedByUser.LoginName returns the user's log-in name who has locked the file. If it is not locked by anyone then it returns null. The code is as below: static void Main(string[] args) { using (SPSite siteCollection = new SPSite(@"")) ...


3

If you are using SharePoint 2013 you can use the client api and register event receivers remotely. E.g. SPRemoteItemEventProperties (http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.client.eventreceivers.spremoteitemeventproperties.aspx). You can even use this api with your embedded javascript. For SharePoint 2010 jQuery may help you to fiddle ...


3

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}


3

No, no OOB settings can prevent a user from overwriting an existing document, unless you do one of the things suggested in the other answers OR you create an event receiver and attach it to your library. In this event receiver, for the itemAdding event handler, you then check if there's another document with the same name and in this case, you cancel the ...


2

Does your list have workflows attached? May be the workflow history list is creating the problem for you too. Its kind of a known issue in SharePoint 2007 if its workflow problem. Read this article for a clear understanding. And another update for this issue is that it might occur for only sites having 'Publishing feature' enabled. (Note: its the site ...


2

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.


2

Some other options would be using a workflow to move data around, assuming it's within the same site collection. You can also use Content and structure to move items from list to list, depending on your SKU. Another option is to use Information Rights Management (IRM). IRM allows you to specify retention times based on dates. When a specific time range ...


2

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 ...


2

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: ...


2

mikey, This is not available OOB... What you can do is create a new Custom Action that will add a button to the ribbon right after the Edit button, follow this on making custom action: http://msdn.microsoft.com/en-us/library/hh500259.aspx In custom action, call a Javascript function in which you can get all the items selected by user, see this URL: ...


2

This isn't supported by SharePoint, so you need to set specific permission on each item, which will only perform well if you have a limited number of items in the list. The setting of permission, can be done: Manually like this: Open list with item Select the item In the ribbon click Item Permissions In the ribbon click Stop Inheriting Permissions (and ...


2

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.


2

This is an architectural change in 2013. See: http://joelblogs.co.uk/2013/02/15/sharepoint-2013-content-databases-and-the-alluserdata-table/


2

Change your function Clicked() to have a parameter. function Clicked(elem) { alert(elem.length); // This is just to alert something } Then in your click event on the <a> tag, add the argument this in Clicked() <a href="javascript:void(0)" onclick="Clicked(this);" title="Add item to card">...</a> The Clicked function should now ...


2

Finally I got my issue resolved. We can directly authenticate Sharepoint Online site by using the below code using (ClientContext clientContext = new ClientContext(siteURL)) { SecureString passWord = new SecureString(); foreach (char c in "password".ToCharArray()) passWord.AppendChar(c); clientContext.Credentials = new ...


2

Check out this MSDN article which help you lot http://code.msdn.microsoft.com/SharePoint-2013-Perform-335d925b



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