1. Click to enter newform.aspx page, edit page, insert Script Editor WebPart, such as:
2, after inserting such as, drag Autorecord WebPart to the script editor above, prevent because of loading order problem cannot find the DOM on the page;
3. Add external references to scripts in the Script Editor, and methods that need to be executed, such as:
4. In the external script to be referenced, write our script, such as:
The principle is to use the script to add a new Save button before the existing Save button, while hiding the default, the function of the new button is to save the field values written into the cookie, and perform the old button save event;
5, create a new record, click on our newly added button "Save2" to save, such as:
6, save after the effect, such as:
7. New project again, will automatically read the value from the cookie, and then assign the value to the title field, such as:
8, Test success, the next job is to modify in the script, hide the Save button, the name of the Save2 button to save, you can complete the work, the final effect such as:
Summarize
The application of the script in SharePoint is very flexible, of course, QQ group in the discussion, there are friends said can write to the backstage, with Ajax to deal with, also are good suggestions;
This article describes the simplest field, that is, a single-line text field, if you encounter a drop-down box and other special fields, you can refer to this article processing, but not necessarily applicable to all situations;
All right, here we go, rest. Take a break.
Complete script included
var cookiename = "Titlefield"; var FieldID = "Title_fa564e0f-0c70-4ab9-b863-0177e6ddd247_$textfield"; var BtnId = "ctl00_ Ctl38_g_ea9475eb_d286_4078_diidiosaveitem "; function GetCookie () {Try{var Arr,reg = new RegExp (" (^|) + cookiename + "= ([ ^;] *) (; |$) "); if (arr = Document.cookie.match (reg)) {document.getElementById (FieldID). Value = Unescape (arr[2]); return Unescape (arr[2]); } else {return null; }}catch (ex) {}}function Setcookie () {var value = document.getElementById (FieldID). Value;var days = 30; var exp = new Date (); Exp.settime (Exp.gettime () + days*24*60*60*1000); Document.cookie = cookiename + "=" + Escape (value) + "; expires=" + exp.togmtstring (); var btn = document.getElementById (Btnid); Btn.click ();} function Bindsavebutton () {var newbtn = "<input type= ' button ' onclick= ' Setcookie () ' value= ' Save ' ></input>" ; var btn = document.getElementById (Btnid); btn.outerhtml = newbtn + "<span style= ' Display:none; ' > "+btn.outerhtml +" </span> ";}
SharePoint 2013 New Project field automatically loads the last saved value