SharePoint 2013 New Project field automatically loads the last saved value

Source: Internet
Author: User

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

1 varCookieName = "Titlefield";2 varFieldID = "Title_fa564e0f-0c70-4ab9-b863-0177e6ddd247_$textfield";3 varBtnid = "ctl00_ctl38_g_ea9475eb_d286_4078_99f1_24eff0577987_ctl00_toolbartbl_rightrptcontrols_ctl00_ctl00_ Diidiosaveitem ";4 5 functionGetCookie ()6 {7     Try8     {9         varArr,reg =NewRegExp ("(^|)" + cookiename + "= ([^;] *)(;|$)");Ten      One         if(arr =Document.cookie.match (reg)) A         { -document.getElementById (FieldID). Value = Unescape (arr[2]); -             returnUnescape (arr[2]);  the         } -         Else -         { -             return NULL; +         } -     } +     Catch(ex) {} A } at  - functionSetcookie () - { -     varValue =document.getElementById (FieldID). value; -     varDays = 30;  -     varExp =NewDate (); inExp.settime (Exp.gettime () + days*24*60*60*1000);  -Document.cookie = cookiename + "=" + Escape (value) + "; expires=" +exp.togmtstring (); to     varBTN =document.getElementById (Btnid); + Btn.click (); - } the  * functionBindsavebutton () $ {Panax Notoginseng     varNEWBTN = "<input type= ' button ' onclick= ' Setcookie () ' value= ' Save ' ></input>"; -     varBTN =document.getElementById (Btnid); thebtn.outerhtml = newbtn + "<span style= ' Display:none; ' > "+btn.outerhtml +" </span> "; +}

SharePoint 2013 New Project field automatically loads the last saved value

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.