A JavaScript client object model sample that fetches a list item attachment by file name.
var clientContext = SP.ClientContext.get_current();
var list = clientContext.get_web().get_lists().getByTitle("LISTNAME");
var listItem = list.getItemById(ID);
clientContext.load(listItem);
clientContext.load(listItem.get_attachmentFiles().getByFileName("FILENAME"));
clientContext.executeQueryAsync(Function.createDelegate(this, onSuccess), Function.createDelegate(this, onFailure));
Start a SharePoint 2010 list workflow from server-side code by finding its association by name.
public void StartWorkFlow(string listName, int itemID, string workflowName)
{
SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite oSite = new SPSite(SPContext.Current.Site.Url))
{
Arrow keys do not raise KeyDown in a WinForm because the form swallows them. Override ProcessCmdKey to catch them.
Public Class Form1
Protected Overrides Function ProcessCmdKey(ByRef msg As Message, ByVal keydata As Keys) As Boolean
If keydata = Keys.Right Then
PictureBox1.Left += 10
End If
Override the HandleFolder function in a Script Editor web part so that folders in a document library open in a new window.
function HandleFolder(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p) {
var parts = new Array();
parts = c.toLowerCase().split('%2f');
c = c.replace('SitePages/Home.aspx', parts[1]);
window.open(c);
return false;
A JSOM function that looks up a managed metadata term by name in a term set and writes name|id into a hidden field.
function GetFullTermStringByName(termName, termSetId, inputId) {
var clientContext = new SP.ClientContext.get_current();
var taxSession = SP.Taxonomy.TaxonomySession.getTaxonomySession(clientContext);
var termStore = taxSession.getDefaultKeywordsTermStore();
var termSet = termStore.getTermSet(termSetId);
var terms = termSet.getAllTerms();
Use jQuery in a Script Editor web part to make list item links open the edit form instead of the display form.
<script type="text/javascript" src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script type="text/javascript">
$(document).ready(function()
{
// Change all display form links to edit form links
$('.ms-vb a[href*="listform.aspx"]').each(function(){