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). It works with SharePoint 2007, 2010, and 2013 (including SharePoint Online / Office 365).

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

144458


Download the latest from GitHub!!

Features:

  • Set or get field values in Document Libraries, all sorts of List forms (custom lists, issues, etc), and survey
  • 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. Auto-populating the form using a URL with query parameters
  4. Auto-populate a list column with a sequential number
  5. Hide/Show field on list form based on value from another field

Keep in mind that SPUtility.js and documentation are still a work in progress... and that it won't work in every situation. It currently will NOT work with:

  1. External list forms
  2. Forms that have been customized using Infopath
  3. Certain (weird) fields, see the matrix of supported fields

Getting Started

To use the library, you can just upload SPUtility.js and dependent files into a document library 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.

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

If you do find something that you would like supported or isn't quite working, please don't hesitate to post a Discussion.

Finally, if you use SPUtility.js and like it, tweet at me! @kitmenke

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

Hide a field from view

Before
144469

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

After
144470

See the Documentation for more information.

Last edited Oct 21 at 8:45 PM by KitMenke, version 52