sharepoint
27 03 2015
On a dev server today I accidentally deleted all the timer jobs from the farm, via a bit of careless PowerShell. But rather than a full Farm rebuild, it’s fairly easily to re-provision all the out of the box timer jobs! Firstly, run the Configuration Wizard to reprovision the Farm-scoped Timer Jobs. Then, for each […]
admin, itpro, SharePoint
27 08 2013
Trying never to use SPList.Items (due to Best Practice), yet needing to grab some items from a list quite often? Here’s an extension method which I use a fair bit.
|
/// <summary> /// Gets items where a property matches a value /// </summary> /// <param name="list">The list.</param> /// <param name="property">The property.</param> /// <param name="value">The value.</param> /// <returns>A list collection of SPListItems</returns> public static IList<SPListItem> ItemsWhere(this SPList list, string property, string value) { SPQuery query = new SPQuery(); query.Query = string.Format("<Where><Eq><FieldRef Name='{0}' /><Value Type='Text'>{1}</Value></Eq></Where>", property, value); SPListItemCollection items = list.GetItems(query); return items.Cast<SPListItem>().ToList(); } |
You can then use regular LINQ queries to get the item or items you need against the object returned by this, for example:
|
SPList webPartCatalog = site.GetCatalog(SPListTemplateType.WebPartCatalog); SPListItem wpItem = webPartCatalog.ItemsWhere("FileLeafRef", "Some Web Part.dwp").FirstOrDefault(); |
[…]
2 08 2013
Here’s a quickie – in SharePoint Sites and Lists, you have the option to let the search indexer crawl the content, setting the “Allow this site to appear in search results”. This is a property on the relevant object called ‘NoCrawl‘. Just set this to true to prevent indexing of the object, or false to […]
17 06 2013
When you try to delete a page layout that’s in use, SharePoint will warn you (or rather, blow up on you) that it’s currently in use, but rather unhelpfully doesn’t tell you which pages are using it. Luckily, a little-known feature in SharePoint that has existed since SharePoint 2007 will list you all the pages […]
13 06 2013
Want to set the Rating for the current page yourself with JavaScript? Here’s how. You will probably need to build your own rating control to get the rating for the current page and render it nicely, but until I figure out the SP JavaScript to update the OOTB control, here’s the code for actually setting […]
24 05 2013
Cut to the chase: github is here: https://github.com/jimmywim/SPMobileI have spent a bit of time recently tidying up and expanding the code possibilities with my iOS library – SPRESTApi. The changes have allowed me to extend it so it’s no longer just a REST API helper, but can be used to called the ASMX web services in […]
14 05 2013
Over on my Github project I have finally got round to doing some updates to the code. I’ve added a class that simplifies Forms Authentication, and allows you to issue the same REST API queries against SharePoint. Code samples are on the wiki on the Github site. Doing this wasn’t really that difficult, you basically […]
25 04 2013
(Concepts here are discussed around SharePoint 2010 but should equally be applicable to SharePoint 2013. All concepts here apply only to full-trust farm solutions, and cannot be done at all with Sandboxed solutions or with the App model)Occasionally you might give given the requirement (as a developer) to provide the ability to insert a chart […]
22 04 2013
Here’s some code to get all PerformancePoint filter selections for the current user in a web site. This is a fairly straightforward operation. First you need a collection of strings, each of which is the URL to a PerformancePoint Filter stored in SharePoint. In this code snippet I use SPSiteDataQuery (in the DiscoverFilterUrls() method). You […]
19 04 2013
For a beginner SharePoint developer, there can be a fair amount of confusion around the seemingly trivial task of building a C# Console Application to connect to a SharePoint site and to learn the object model. You merely include a reference to the Microsoft.SharePoint.dll assembly, instantiate an object, passing in your site URL and you’re […]