Tag Info

Hot answers tagged

7

If fetching of item["ID"] instead of 'Title' works AND If you are using the SPQuery object. Then, include the columns that you want to fetch in the ViewFields property of SPQuery. This will resolve your issue. Reference: ...


3

First add the List Item so its Id is generated, than get the item again... Update its Title field and concat Id column with it.. Pseudo-code below: ListItem newItem = lstObject.Items.Add(); newItem["Field"] = "something"; newItem.Update(); newItem = lstObject.Items.GetItemById(newItem.Id); newItem["Title"] = "YourText" + newItem.Id.ToString(); ...


3

You can create a custom permission level that allows adding but not editing. See this MSDN article about how to do that. You will want to copy the contribute permission but remove the edit permissions.


3

What is happening is that your event receiver is kicking in before your PowerShell is done, and modifying it on a different thread before your PowerShell update occurs. When SharePoint hits your update statement, it sees that the item in the database is no longer the same as the one it's trying to update. I've got 3 different approaches: Set all of your ...


3

So you have UniqueId of the item and the Url of the library, right? You can get the item in one of the following ways: Get the list from the Url SPList list = web.GetList("http://mysharepoint.be/MYDOCUMENTSLIBRARY"); SPListItem item = list.GetItemByUniqueId(yourGuid); Get the list form the Url of a webpart page that has a web part for your list as first ...


3

You need to use the $expand option in your query string. siteUrl + "/_api/lists/getbytitle('" + listName + "')/items?$select=NameOfLookup/FieldYouWant&$expand=NameOfLookup/NameOfFieldYouWant" So yours would be: "/_api/lists/getbytitle('" + listName + "')/items?$select=$expand=status_x0028_test_x0029/Title&$expand=status_x0028_test_x0029/Title ...


2

I would say reasons might be due to a combination of facts: you are actually creating a new instance under "System account" - which could practically mean executing in the context of another user. - Use SystemUpdate instead to avoid Version and other automatic column updates - Consider using Synchronous on the receiver declaration (Elements.xml) to avoid ...


2

Instead of creating a new SPFieldUserValue find the one in the SPFieldValueCollection you want to remove like this: private static void DeleteUserFromList(SPUser userDeleted, string fieldName, SPListItem item, SPWeb sPWeb) { SPFieldUserValueCollection Users = (SPFieldUserValueCollection)item[fieldName]; SPFieldUserValue DeletedUserValue = ...


2

When updating a list item you should use the uri from the metdata of the list item you want to edit results[i].__metadata.uri. $(document).ready(function () { var defaultClient = OData.defaultHttpClient; var spClient = { request: function (request, success, error) { request.headers = { "Accept": "application/json;odata=verbose", ...


2

To my knowledge dates are stored as sequential serial numbers so they can be used in calculations. By default, December 31 1899 is serial number 1, and January 1, 2008 is serial number 39448 because it is 39,448 days after January 1, 1900. Time also as part of a date value is also represented as decimal number (for example, 12:00 PM is represented as 0.5 ...


2

For lists and libraries, SharePoint locks the URLs to whatever value the name was when the list/library was created. Later, if you rename the list/library, it will reflect the new name everywhere except in the URL. From your description, it sounds like you are saying the URL..... http://mysharepoint.be/MYDOCUMENTLIBRARY .....works, but the library name ...


1

You can use EffectiveBasePermissions to get the effective base permissions of the current user for a particular list (MyList.EffectiveBasePermissions & SPBasePermissions.ViewListItems) != SPBasePermissions.EmptyMask For a particular item (normally under broken inheritance): Listitem.DoesUserHavePermissions(myuser, SPBasePermissions.ViewListItems) ...


1

instead of: SPContext.executeQueryAsync(GetListItemById); do: SPContext.executeQueryAsync(Function.createDelegate(this, this.GetListItemById_Successor), Function.createDelegate(this, this.GetListItemById_Fail)); http://msdn.microsoft.com/en-us/library/hh185007(v=office.14).aspx


1

I've done some large list stuff as well - not 100,000 items worth, but definitely more than 1000 - and I haven't seen any dispose issues with SPLIstItem. I do know that SharePoint attempts to thread processes behind the scenes when it can; is the OWSTIMER.exe getting so large that it crashes your system, or are you just concerned that it might be getting ...


1

Since the problem seems to be related to the Publish of the file, try this approach: SPFile fileDest = libDest.RootFolder.Files.Add( urlDestFile, streamFile, hashSourceProp, userCreatedBy, userModifiedBy, dateCreatedOn, ...


1

To create a SPUserField in PowerShell you can use $user=New-Object Microsoft.SharePoint.SPFieldUserValue(web, $userId, $userName) $item[[Microsoft.SharePoint.SPBuiltInFieldId]::Editor] = $user $item[[Microsoft.SharePoint.SPBuiltInFieldId]::Modified_x0020_By] = $user $item.SystemUpdate($false);


1

You must change your query to: "<Where><Eq><FieldRef Name='User' />"+ "<Value Type='User'>"+ currentUser.LoginName +"</Value></Eq></Where>" See the link for details


1

You can use AjaxFileUpload. Have a look at the demo on below link. http://www.asp.net/ajaxLibrary/AjaxControlToolkitSampleSite/ajaxFileUpload/ajaxFileUpload.aspx


1

Try Console.WriteLine("{0} -- {1}",item[SPBuiltInFieldId.Department] == null ? "N/A" : item[SPBuiltInFieldId.Department].ToString(), item[SPBuiltInFieldId.Office] == null ? "N/A" : item[SPBuiltInFieldId.Office].ToString()); In the event receivers you can set those two columns. With calculated columns would be great but as far as I know that's not ...


1

Try the below code, SPFieldUserValueCollection fuvc = item[fieldName] as SPFieldUserValueCollection; foreach (SPFieldUserValue value in fuvc) { if (value.LookupId == userDeleted.ID) { fuvc.Remove(value); item[fieldName] = fuvc; item.Update(); break; } } Hope this helps you.


1

It was how I did in one of my projects. TaxonomyField tf = currentPublishingPage.ListItem.Fields[NEWS_TAGS_COLUMN_NAME] as TaxonomyField; TaxonomyFieldValueCollection tfvc = currentPublishingPage.ListItem["Enterprise Keywords"] as TaxonomyFieldValueCollection; Read the Full article


1

Working with taxonomy fields can be tricky... In order to clear a value from a field: $taxField = $item.Fields["metadataField"] -as [Microsoft.SharePoint.Taxonomy.TaxonomyField] $taxFieldValue = $taxField.GetFieldValue(""); $taxField.SetFieldValue($fileItem,$taxFieldValue) $fileItem.Update() In order to set a taxonomy field you essentially need to know ...


1

I am unable to find the exact reason for the error: However pls go through the following points: 1) How to update a Readonly field. First set Readonly to false and update the field and then revert it back as: Field.ReadOnlyField = false; Field.Update(); 2) Updating the Lookupfield: new SPFieldLookupValue(1, "ASP.Net");


1

HandleEventFiring handleEventFiring = new HandleEventFiring(); handleEventFiring.DisableHandleEventFiring(); try { var parentDoc = documentLibrary.GetItemByUniqueId(parentId); parentDoc.Delete(); } finally ...


1

//To get the SPFile reference to the attachment just use this code SPFile attachmentFile = web.GetFile(attachmentAbsURL); // To read the file content simply use this code Stream stream = attachmentFile.OpenBinaryStream(); StreamReader reader = new StreamReader(stream); String fileContent = reader.ReadToEnd();


1

"the SPAttachmentCollection is simply an array of strings representing the file name of each attachment" from http://stackoverflow.com/questions/1334893/sharepoint-spattachmentcollection-a-collection-of-what-exactly Here, from the same link, is an example of usage: var attachments in item.Attachments; foreach (string fileName in attachments) { ...


1

It's possible to do it through Lists web service, GetListItems method: Lists.GetListItems This method will return result in xml format that will contain ows_MetaInfo attribute that will have all SPListItem.Properties.


1

You are calling base.ItemAdding from within the ItemAdded event receiver. It may not be the actual cause of the problem, but it's the first thing I would fix. public override void ItemAdded(SPItemEventProperties properties) { logULS("ItemAdded Started."); base.ItemAdding(properties);


1

Since you are dealing with the somewhat limited environment of FoxPro, there is a possible low tech alternative. Simply map a network drive to the desired SharePoint library and then save the files in FoxPro to that drive. Using the SharePoint Web Services is obviously the superior answer (for several reasons) but this might be quicker in a controlled ...


1

Have you seen this answer? It's newer Office files that appear to be using this format. SharePoint is quite happy reading and writing them to/from this format, however you'll need to do a bit of work if you want to convert the hex to a DateTime value. The hex value represents the number of ticks since 1st Jan 1600, so you may have found that your dates ...



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