Pre-Save Action on Document Libraries In SharePoint 2013 And Office 365


Welcome to an article on ‘Pre-Save Action on Document Libraries in SharePoint 2013 and Office 365.’ We developers face an issue when our client wants to have an action done on a document library on a save click.

Document Library uploads the document, and to validate something on the save click is tricky as the save by passes the validation and gets saved.

Solution:

The solution to do any JavaScript validation is Pre Save action. So here is what you need to do.

  • Open your Document Library
  • Under the ‘Library’tab , click on the Form Web Parts.

    form

  • Choose Default Edit Form, you will see the screen below.

    main

  • Click on Add a Web Part,

    add

  • Choose Script Editor, under the Media and Content Web part.

    script

  • Click on Edit Snippet, you will see the screen below.

    embed

  • Use the code below and click Ok.

    Code:

    1. “/jquery-1.8.3.min.js” type=“text/javascript”>
    2. “/jquery.SPServices-0.7.2.min.js” type=“text/javascript”>
    3. “text/javascript”>
    4. $(document).ready(function()
    5. {
    6. });
    7. function PreSaveAction()
    8. {
    9. }

    a. Use the function PreSaveAction() and paste your validation under the function on the code.

    b. Before saving document library the code will check your validation and will get saved.

Doesn’t it solve a lot of queries related to document libraries functions? Keep learning!
Advertisements

One thought on “Pre-Save Action on Document Libraries In SharePoint 2013 And Office 365

  1. Pingback: Pre-Save Action on Document Libraries In SharePoint 2013 And Office 365 | SharePoint World by Manpreet

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s