Tag Info

Hot answers tagged

8

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


6

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

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


4

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


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

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

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


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

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

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

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

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

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

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

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

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

You need to create two lists, Issues and Discussions with a lookup column on each referring to the other list (so, in the Issues list the lookup column points to Discussions and in the Discussions list the lookup column points to Issues). Then, you create a worflow attached to the Issues list with the following configuration: Inside the "Create item in ...


1

DocumentId is populated by "Document ID Service" feature in SharePoint that can be turned on and off at the site collection level which means that the field may or may not be populated. When active, it provides a way to locate the document regardless of its current name or location. Item Id provides a unique integer for the document within a specific list ...


1

Same issue i faced recently, but resolved with lot of research. The above mentioned issue will come duplicate columns exist in your List schema file. verify your List schema once.... Still the problem exist, follow the below trick verify your "ColName" attribute for every Field, it should be UNIQUE for every Field. because Colname attribute defines the ...


1

This article seems to be helpful: Enhanced Workflow Initiation Forms in SPD – Part II Part I of it Update: This article seems to refer to SPD2010 workflow on Sharepoint Foundation 2010 while on Sharepoint Server 2010 (and before but not after ( * )) any created workflow is based on Infopath forms. Read, for example in: S.Y.M. Wong-A-Ton. 2 ...


1

Best practice wise, I would manually create a lookup field to your project task list (pointing the task id and displaying the task title). On your document library, you could add that field (mandatory if it's sole purpose is to store project task documents) so that whenever someone upload a document, that person has to fill the associated project task. In ...


1

BlueChippy, That really depends upon the views and data usage, but you need to keep in mind the future changes you may need to do for both - if they are not going to change and have almost same kind of data as you said.. And there are several views in which data from both should be populated and filters should be applied on both data or something, then you ...


1

1 - As far as I know, Created and Modified fields are read only fields on SharePoint, so even if you're accessing in the right way, you wont be able to update their values. 2 - By all means, avoid using web.Lists["ListName"]. Instead use web.Lists.TryGetList("ListName"). Your app/script performance will improve


1

You can assigne the unique permissions for an user, but When there are many unique permissions in a list then it can reduce the overall performance of the query so that isn’t recommended. The number of unique permission in a list gets bigger over time and that reduces the performance. While the limit is by default 50,000 it is ideal if you make ...


1

Wrapping the Query inside "View" tags fixed the issue. Its only returning according to the filename now. q.ViewXml = @"<View> <Query> <Where> <Eq> <FieldRef Name='FileLeafRef' /> ...



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