none
PreSaveItem or PreSaveAction SP 2010 question

    Întrebare

  • Hi all,
        I have a custom form and as you can see below i have succesfuly added  a value to the textbox when the form is loaded and i can see it.(Pre filled a textbox field)

    And i would like to insert the value to a field

    I have done this in SP 2007 so many times and it works using PreSaveAction.in SP 2010 is
    PreSaveAction or PreSaveItem ??
    Basically i'm having problem with the PreSaveItem as when i submit my form it doesn't get to insert the value but it redirects.

    	<input type="button" value="Submit" name="Submit" onclick="if (!PreSaveItem()) return false;{ddwrt:GenFireServerEvent('__commit;__redirect={Submitted.aspx}')}" />
    		
    		

    <script type="text/javascript"> function PreSaveItem(){ $("input[Title='Location']").attr("disabled",""); //var t = $("input[Title='Location']").attr("disabled",""); alert("t"); return true; } </script>

    Thanks
    22 martie 2012 06:32

Toate mesajele

  • Hi Patrick,

    Here is some info on how to add a value to a field with jquery:

    http://www.balestra.be/2011/05/automatically-fill-in-fields-via-jquery-in-sharepoint.html

    <script> 
    $(document).ready(function() {   
    var fieldToAddText = $(":input[title='field where you want to put a value in']");  
    if( fieldToAddText .val() != undefined ) {    fieldToAddText .val("add some text"); 
     }; 
    };
    </script>
    You don't need a PreSaveAction() to fill in the field when the page loads: PreSaveAction() only runs when you click on the save button.

    http://www.balestra.be || @marijnsomers

    22 martie 2012 07:34
  • Thanks Marijn
    I didn't have my PreSaveItem in my jquery code.
    Cheers
    But one other thing is what do i need to do if i want to enable the textbox when doing presave and disable it later.

    If i disable the textbox it simply doesn't insert the data.

    Cheers

    23 martie 2012 00:46
  • It may be necessary to retrieve information when save is clicked and then populate fields.  This would be done in the PreSaveAction but does not work. 
    27 februarie 2013 21:23
  • I'm experiencing the same problem.  Is Microsoft going to address this?  It's now 2013 and no progress.  Come on Microsoft, get involved!
    27 februarie 2013 21:24