1

I have a basic custom list with items that open in a modal display form. I need to get the value of one of the fields, store it in a javascript variable, and further process it. How do I get the field value?

1
  • If you have the item ID, you can query it using the rest api to get field values.
    – Akhoy
    Mar 11, 2016 at 8:40

1 Answer 1

2

If you want get field value on item Display Form. Then you achieve this using SPUtility.js

Steps:

  1. Edit view item form in SharePoint UI.
  2. Add Script editor web part.
  3. Give reference of "sputitly.js" and jquery.min.js

    <script src="/jquery.min.js" type="text/javascript"></script>
    <script src="/sputility.js" type="text/javascript"></script>
    
  4. Add the following script in script tag.

    <script type="text/javascript">
    $(document).ready(function () {
    var fldValue= SPUtility.GetSPField('Your Column Name').GetValue();
    });
    </script>
    
  5. Ok & Save the page.

"Your field value will be stored in "fldValue" javascript variable."

SPUtility.js is a JavaScript library used to make modifications to SharePoint's list forms (NewForm.aspx, DispForm and EditForm.aspx in a survey, custom list or library). It works with SharePoint 2007, 2010, and 2013 (including SharePoint Online / Office 365).

SPUtility.js Documentation

1
  • Thanks. Also just wanted to point out that .GetValue() needs to be appended at the end like so: fldValue= SPUtility.GetSPField('Your Column Name').GetValue() Mar 11, 2016 at 12:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.