Search
April 26, 2011 Update: Version 0.8 released! See the Changelog or the post on my blog for more info.

Description:

SPUtility.js is a JavaScript library used to make modifications to SharePoint's list forms (NewForm.aspx and EditForm.aspx in a survey, custom list or library). This library depends on Prototype.js. SPUtility.js has been tested in SharePoint 2007 with WSS 3.0 and MOSS (untested in SharePoint 2010 but reported as working by some users).

This library and documentation is still a work in progress, so any feedback is greatly appreciated.

Features:
  • Set or get field values
  • Make a field read only
  • Hide a field from view
  • No server side code to deploy!
This can be used for:
  1. Preventing a user from selecting a value when an item is initially created (ex: Status must be PENDING when the item is created)
  2. Hiding fields from a submitter but allowing the field to be edited (or vice versa).
  3. Autopopulating the form using a URL with query parameters

See the Documentation for the matrix of supported fields and API documentation. Browse the Changelog to see the list of updates.

Usage Examples:

Set a Text field's value

SPUtility.GetSPField('Title').SetValue('Hello world!');

144458

Set a Text field's value and make it read only

SPUtility.GetSPField('Title').SetValue('Hello world!').MakeReadOnly();

144459

Make a Choice field read only

Before
144471

SPUtility.GetSPField('Status').MakeReadOnly();

After
144468

Set a People field and/or Make it Read Only

SPUtility.GetSPField('Assigned To').SetValue('Menke, Kit');

152982

SPUtility.GetSPField('Assigned To').MakeReadOnly();

152983

Hide a field from view

Before
144469

SPUtility.GetSPField('% Complete').Hide();

After
144470

See the Documentation for more information.

Installation

To use the library, you'll need to upload SPUtility.js and prototype.js into SharePoint (a document library perhaps) and put a Content Editor Web Part with some JavaScript code on whichever page you want to modify! Detailed instructions are on the Installation page.
Last edited Apr 27 2011 at 2:59 AM by KitMenke, version 34
Updating...
© 2006-2012 Microsoft | Get Help | Privacy Statement | Terms of Use | Code of Conduct | Advertise With Us | Version 2012.1.11.18365