none
Using Jquery/JavaScript - Is any way to output column names and column values on EditForm.aspx? RRS feed

  • Question

  • Hi there

    I have searched high and low - but could not find any JQuery/JavaScript that can:

    // Run on EditForm.aspx
    Foreach Column in SPList
    {
     alert(Column Name + Column Value for current item on EditForm.aspx) 
    }

    Any help will be appreciated!

    Thanks so much.

    Friday, March 17, 2017 5:21 PM

All replies

  • You can go to List and click on 'Form Web Parts' -> 'Default Edit Form'

     Click on 'Settings' -> 'Edit Page'

    Click on 'Add a Webpart' and a add 'Media and Content' -> 'Script Editor'

    Add following script : 

    <script language="javascript" type="text/javascript">
      
    _spBodyOnLoadFunctionNames.push("showID");
      
    function showID()
    {
    var querystring = location.search.substring(1, location.search.length);
    var ids = querystring.split("&")[0];
    var id = ids.split("=")[1];
    var clientContext = new SP.ClientContext();
    var list = clientContext.get_web().get_lists().getByTitle(_spPageContextInfo.listTitle);
    
    // Current Edit List Item
    var listItem = list.getItemById(id);
    
    //.... Performed required operations
    
    
    }
    </script>
    listItem variable will have data of current list item, now you can perform operations as per need.


    get2pallav
    Please click "Propose As Answer" if this post solves your problem or "Vote As Helpful" if this post has been useful to you.


    Saturday, March 18, 2017 1:29 AM
  • Hi ran009,

    Can you please confirm that if the reply helpful to you?

    Best regards,

    Patrick Liang


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Saturday, March 25, 2017 5:04 AM
    Moderator
  • Unfortunately not; I am still looking.

    Thanks.

    Saturday, March 25, 2017 3:48 PM
  • Hi,

    Actually, with the id of an item, we can query the column names and column values with the help of JavaScript Client Object Model, just like what suggested by get2pallav:

    https://msdn.microsoft.com/en-us/library/office/hh185007(v=office.14).aspx

    Feel free to reply if there is still any doubt about it.

    Best regards,

    Patrick

    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Monday, March 27, 2017 1:08 AM
    Moderator
  • Hi Patrick

    This script is retrieving list items, from list (which I do NOT need).

    What I need is a script to run on EditForm.aspx that can alert (or write in console) all column names along their values.

    Any other thoughts please?

    Thanks.

    Monday, March 27, 2017 8:46 PM
  • Hi,

    What we can see about the fields and values on the EditForm.aspx page is only a subset of the data which can be retrieved from an item.

    Actually, the script is trying to retrieve an item by id, it will return all the column names along with their values, you can extract the values you want from the result based on your need.

    Best regards,

    Patrick Liang


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Wednesday, March 29, 2017 12:27 PM
    Moderator
  • For anyone else who needs this - this worked for me https://social.msdn.microsoft.com/Forums/office/en-US/6a17967c-e3b5-48d3-a5d8-68339427451b/

    Thanks.

    Wednesday, March 29, 2017 10:31 PM
  • Hi,

    Glad to hear that you solve the issue, thanks for your sharing.

    If the original issue has been resolved, it would be appreciated if you can mark the reply as answer, others who stuck with the similar issue would be easier to search for valid solutions in this forum.

    Thanks,               

    Patrick Liang



    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Thursday, March 30, 2017 1:20 AM
    Moderator